32 [
'overwrite',
'overwriteSame',
'ignoreMissingSource',
'headers' ],
41 $status = StatusValue::newGood();
45 if ( $srcExists ===
false ) {
46 if ( $this->
getParam(
'ignoreMissingSource' ) ) {
53 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
57 } elseif ( $srcExists === FileBackend::EXISTENCE_ERROR ) {
58 $status->fatal(
'backend-fail-stat', $this->params[
'src'] );
63 $srcSize =
function () use ( $opPredicates ) {
65 $size ??= $this->
resolveFileSize( $this->params[
'src'], $opPredicates );
68 $srcSha1 =
function () use ( $opPredicates ) {
77 if ( $status->isOK() ) {
78 $batchPredicates->
assumeFileExists( $this->params[
'dst'], $srcSize, $srcSha1 );
79 if ( $this->params[
'src'] !== $this->params[
'dst'] ) {
88 if ( $this->overwriteSameCase ) {
89 if ( $this->params[
'src'] === $this->params[
'dst'] ) {
91 $status = StatusValue::newGood();
94 $status = $this->backend->deleteInternal( $this->
setFlags(
95 [
'src' => $this->params[
'src'] ]
98 } elseif ( $this->params[
'src'] === $this->params[
'dst'] ) {
100 $headers = $this->
getParam(
'headers' ) ?: [];
101 $status = $this->backend->describeInternal( $this->
setFlags(
102 [
'src' => $this->params[
'dst'],
'headers' => $headers ]
106 $status = $this->backend->moveInternal( $this->
setFlags( $this->params ) );
113 return [ $this->params[
'src'] ];
117 return [ $this->params[
'src'], $this->params[
'dst'] ];
FileBackend helper class for representing operations.
resolveFileExistence( $source, FileStatePredicates $opPredicates)
Check if a file will exist in storage when this operation is attempted.
precheckDestExistence(FileStatePredicates $opPredicates, $sourceSize, $sourceSha1)
Check for errors with regards to the destination file already existing.
getParam( $name)
Get the value of the parameter with the given name.
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
resolveFileSha1Base36( $source, FileStatePredicates $opPredicates)
Get the SHA-1 of a file in storage when this operation is attempted.
resolveFileSize( $source, FileStatePredicates $opPredicates)
Get the size a file in storage will have when this operation is attempted.
Helper class for tracking counterfactual file states when pre-checking file operation batches.
assumeFileExists(string $path, $size, $sha1Base36)
Predicate that a file exists at the path.
assumeFileDoesNotExist(string $path)
Predicate that no file exists at the path.
Move a file from one storage path to another in the backend.
doPrecheck(FileStatePredicates $opPredicates, FileStatePredicates $batchPredicates)
Do a dry-run precondition check of the operation in the context of op batch.
storagePathsRead()
Get a list of storage paths read from for this operation.
allowedParams()
Get the file operation parameters.
storagePathsChanged()
Get a list of storage paths written to for this operation.