MediaWiki master
|
Helper class for tracking counterfactual file states when pre-checking file operation batches. More...
Public Member Functions | |
__construct () | |
assumeFileDoesNotExist (string $path) | |
Predicate that no file exists at the path. | |
assumeFileExists (string $path, $size, $sha1Base36) | |
Predicate that a file exists at the path. | |
resolveFileExistence (string $path, $curExistenceFunc) | |
Get the hypothetical existance a file given predicated and current state of files. | |
resolveFileSha1Base36 (string $path, $curSha1Func) | |
Get the hypothetical SHA-1 hash of a file given predicated and current state of files. | |
resolveFileSize (string $path, $curSizeFunc) | |
Get the hypothetical size of a file given predicated and current state of files. | |
snapshot (array $paths) | |
Protected Attributes | |
const | EXISTS = 'exists' |
const | SHA1 = 'sha1' |
const | SIZE = 'size' |
Helper class for tracking counterfactual file states when pre-checking file operation batches.
The file states are represented with (existence,size,sha1) triples. When combined with the current state of files in the backend, this can be used to simulate how a batch of operations would play out as a "dry run". This is used in FileBackend::doOperations() to bail out if any failure can be predicted before modifying any data. This includes file operation batches where the same file gets modified by different operations within the batch.
Definition at line 37 of file FileStatePredicates.php.
Wikimedia\FileBackend\FileOps\FileStatePredicates::__construct | ( | ) |
Definition at line 45 of file FileStatePredicates.php.
Wikimedia\FileBackend\FileOps\FileStatePredicates::assumeFileDoesNotExist | ( | string | $path | ) |
Predicate that no file exists at the path.
string | $path | Storage path |
Definition at line 69 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\CopyFileOp\doPrecheck(), Wikimedia\FileBackend\FileOps\DeleteFileOp\doPrecheck(), and Wikimedia\FileBackend\FileOps\MoveFileOp\doPrecheck().
Wikimedia\FileBackend\FileOps\FileStatePredicates::assumeFileExists | ( | string | $path, |
$size, | |||
$sha1Base36 ) |
Predicate that a file exists at the path.
string | $path | Storage path |
int | false | Closure | $size | File size or idempotent function yielding the size |
string | Closure | $sha1Base36 | File hash, or, idempotent function yielding the hash |
Definition at line 56 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\CopyFileOp\doPrecheck(), Wikimedia\FileBackend\FileOps\CreateFileOp\doPrecheck(), Wikimedia\FileBackend\FileOps\DescribeFileOp\doPrecheck(), Wikimedia\FileBackend\FileOps\MoveFileOp\doPrecheck(), and Wikimedia\FileBackend\FileOps\StoreFileOp\doPrecheck().
Wikimedia\FileBackend\FileOps\FileStatePredicates::resolveFileExistence | ( | string | $path, |
$curExistenceFunc ) |
Get the hypothetical existance a file given predicated and current state of files.
string | $path | Storage path |
Closure | $curExistenceFunc | Function to compute the current existence for a given path |
Definition at line 84 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\FileOp\resolveFileExistence().
Wikimedia\FileBackend\FileOps\FileStatePredicates::resolveFileSha1Base36 | ( | string | $path, |
$curSha1Func ) |
Get the hypothetical SHA-1 hash of a file given predicated and current state of files.
string | $path | Storage path |
Closure | $curSha1Func | Function to compute the current SHA-1 hash for a given path |
Definition at line 106 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\FileOp\resolveFileSha1Base36().
Wikimedia\FileBackend\FileOps\FileStatePredicates::resolveFileSize | ( | string | $path, |
$curSizeFunc ) |
Get the hypothetical size of a file given predicated and current state of files.
string | $path | Storage path |
Closure | $curSizeFunc | Function to compute the current size for a given path |
Definition at line 95 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\FileOp\resolveFileSize().
Wikimedia\FileBackend\FileOps\FileStatePredicates::snapshot | ( | array | $paths | ) |
string[] | $paths | List of storage paths |
Definition at line 136 of file FileStatePredicates.php.
References $path.
Referenced by Wikimedia\FileBackend\FileOps\FileOp\precheck().
|
protected |
Definition at line 38 of file FileStatePredicates.php.
|
protected |
Definition at line 40 of file FileStatePredicates.php.
|
protected |
Definition at line 39 of file FileStatePredicates.php.