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 );
85 if ( $this->overwriteSameCase ) {
86 $status = StatusValue::newGood();
87 } elseif ( $this->params[
'src'] === $this->params[
'dst'] ) {
89 $headers = $this->
getParam(
'headers' ) ?: [];
90 $status = $this->backend->describeInternal( $this->
setFlags( [
91 'src' => $this->params[
'dst'],
'headers' => $headers
95 $status = $this->backend->copyInternal( $this->
setFlags( $this->params ) );
102 return [ $this->params[
'src'] ];
106 return [ $this->params[
'dst'] ];
Copy a file from one storage path to another in the backend.
allowedParams()
Get the file operation parameters.
storagePathsChanged()
Get a list of storage paths written to for this operation.
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.
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.