本文整理汇总了PHP中FileBackend::getFileSha1Base36方法的典型用法代码示例。如果您正苦于以下问题:PHP FileBackend::getFileSha1Base36方法的具体用法?PHP FileBackend::getFileSha1Base36怎么用?PHP FileBackend::getFileSha1Base36使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileBackend
的用法示例。
在下文中一共展示了FileBackend::getFileSha1Base36方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doTestDoOperationsFailing
private function doTestDoOperationsFailing()
{
$base = self::baseStorePath();
$fileA = "{$base}/unittest-cont2/a/b/fileA.txt";
$fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
$fileB = "{$base}/unittest-cont2/a/b/fileB.txt";
$fileBContents = 'g-jmq3gpqgt3qtg q3GT ';
$fileC = "{$base}/unittest-cont2/a/b/fileC.txt";
$fileCContents = 'eigna[ogmewt 3qt g3qg flew[ag';
$fileD = "{$base}/unittest-cont2/a/b/fileD.txt";
$this->prepare(array('dir' => dirname($fileA)));
$this->create(array('dst' => $fileA, 'content' => $fileAContents));
$this->prepare(array('dir' => dirname($fileB)));
$this->create(array('dst' => $fileB, 'content' => $fileBContents));
$this->prepare(array('dir' => dirname($fileC)));
$this->create(array('dst' => $fileC, 'content' => $fileCContents));
$status = $this->backend->doOperations(array(array('op' => 'copy', 'src' => $fileA, 'dst' => $fileC, 'overwrite' => 1), array('op' => 'copy', 'src' => $fileC, 'dst' => $fileA, 'overwriteSame' => 1), array('op' => 'copy', 'src' => $fileB, 'dst' => $fileD, 'overwrite' => 1), array('op' => 'move', 'src' => $fileC, 'dst' => $fileD), array('op' => 'move', 'src' => $fileB, 'dst' => $fileC, 'overwriteSame' => 1), array('op' => 'move', 'src' => $fileB, 'dst' => $fileA, 'overwrite' => 1), array('op' => 'delete', 'src' => $fileD), array('op' => 'null')), array('force' => 1));
$this->assertNotEquals(array(), $status->errors, "Operation had warnings");
$this->assertEquals(true, $status->isOK(), "Operation batch succeeded");
$this->assertEquals(8, count($status->success), "Operation batch has correct success array");
$this->assertEquals(false, $this->backend->fileExists(array('src' => $fileB)), "File does not exist at {$fileB}");
$this->assertEquals(false, $this->backend->fileExists(array('src' => $fileD)), "File does not exist at {$fileD}");
$this->assertEquals(true, $this->backend->fileExists(array('src' => $fileA)), "File does not exist at {$fileA}");
$this->assertEquals(true, $this->backend->fileExists(array('src' => $fileC)), "File exists at {$fileC}");
$this->assertEquals($fileBContents, $this->backend->getFileContents(array('src' => $fileA)), "Correct file contents of {$fileA}");
$this->assertEquals(strlen($fileBContents), $this->backend->getFileSize(array('src' => $fileA)), "Correct file size of {$fileA}");
$this->assertEquals(wfBaseConvert(sha1($fileBContents), 16, 36, 31), $this->backend->getFileSha1Base36(array('src' => $fileA)), "Correct file SHA-1 of {$fileA}");
}
示例2: filesAreSame
protected function filesAreSame(FileBackend $src, FileBackend $dst, $sPath, $dPath)
{
return $src->getFileSize(['src' => $sPath]) === $dst->getFileSize(['src' => $dPath]) && $src->getFileSha1Base36(['src' => $sPath]) === $dst->getFileSha1Base36(['src' => $dPath]);
}
示例3: getFileSha1
/**
* Get the sha1 (base 36) of a file with a given virtual URL/storage path
*
* @param string $virtualUrl
* @return string|bool
*/
public function getFileSha1($virtualUrl)
{
$path = $this->resolveToStoragePath($virtualUrl);
return $this->backend->getFileSha1Base36(array('src' => $path));
}
示例4: filesAreSame
/**
* @param FileBackend $src
* @param FileBackend $dst
* @param string $sPath
* @param string $dPath
* @return bool
*/
protected function filesAreSame( FileBackend $src, FileBackend $dst, $sPath, $dPath ) {
$skipHash = $this->hasOption( 'skiphash' );
$srcStat = $src->getFileStat( array( 'src' => $sPath ) );
$dPathSha1 = sha1( $dPath );
$dstStat = isset( $this->statCache[$dPathSha1] )
? $this->statCache[$dPathSha1]
: $dst->getFileStat( array( 'src' => $dPath ) );
return (
is_array( $srcStat ) // sanity check that source exists
&& is_array( $dstStat ) // dest exists
&& $srcStat['size'] === $dstStat['size']
&& ( !$skipHash || $srcStat['mtime'] <= $dstStat['mtime'] )
&& ( $skipHash || $src->getFileSha1Base36( array( 'src' => $sPath, 'latest' => 1 ) )
=== $dst->getFileSha1Base36( array( 'src' => $dPath, 'latest' => 1 ) )
)
);
}
示例5: filesAreSame
/**
* @param FileBackend $src
* @param FileBackend $dst
* @param string $sPath
* @param string $dPath
* @return bool
*/
protected function filesAreSame(FileBackend $src, FileBackend $dst, $sPath, $dPath)
{
$skipHash = $this->hasOption('skiphash');
$srcStat = $src->getFileStat(['src' => $sPath]);
$dPathSha1 = sha1($dPath);
if ($this->statCache !== null) {
// All dst files are already in stat cache
$dstStat = isset($this->statCache[$dPathSha1]) ? $this->statCache[$dPathSha1] : false;
} else {
$dstStat = $dst->getFileStat(['src' => $dPath]);
}
// Initial fast checks to see if files are obviously different
$sameFast = is_array($srcStat) && is_array($dstStat) && $srcStat['size'] === $dstStat['size'];
// More thorough checks against files
if (!$sameFast) {
$same = false;
// no need to look farther
} elseif (isset($srcStat['md5']) && isset($dstStat['md5'])) {
// If MD5 was already in the stat info, just use it.
// This is useful as many objects stores can return this in object listing,
// so we can use it to avoid slow per-file HEADs.
$same = $srcStat['md5'] === $dstStat['md5'];
} elseif ($skipHash) {
// This mode is good for copying to a backup location or resyncing clone
// backends in FileBackendMultiWrite (since they get writes second, they have
// higher timestamps). However, when copying the other way, this hits loads of
// false positives (possibly 100%) and wastes a bunch of time on GETs/PUTs.
$same = $srcStat['mtime'] <= $dstStat['mtime'];
} else {
// This is the slowest method which does many per-file HEADs (unless an object
// store tracks SHA-1 in listings).
$same = $src->getFileSha1Base36(['src' => $sPath, 'latest' => 1]) === $dst->getFileSha1Base36(['src' => $dPath, 'latest' => 1]);
}
return $same;
}
示例6: filesAreSame
protected function filesAreSame(FileBackend $src, FileBackend $dst, $sPath, $dPath)
{
$skipHash = $this->hasOption('skiphash');
return $src->fileExists(array('src' => $sPath, 'latest' => 1)) === $dst->fileExists(array('src' => $dPath, 'latest' => 1)) && $src->getFileSize(array('src' => $sPath, 'latest' => 1)) === $dst->getFileSize(array('src' => $dPath, 'latest' => 1)) && ($skipHash || $src->getFileSha1Base36(array('src' => $sPath, 'latest' => 1)) === $dst->getFileSha1Base36(array('src' => $dPath, 'latest' => 1)));
}