24use Wikimedia\AtEase\AtEase;
34 [
'overwrite',
'overwriteSame',
'headers' ],
43 $status = StatusValue::newGood();
46 if ( !is_file( $this->params[
'src'] ) ) {
47 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
53 $maxFileSize = $this->backend->maxFileSizeInternal();
54 if ( $sourceSize > $maxFileSize ) {
55 $status->fatal(
'backend-fail-maxsize', $this->params[
'dst'], $maxFileSize );
60 $sourceSha1 =
function () {
69 if ( $status->isOK() ) {
70 $batchPredicates->
assumeFileExists( $this->params[
'dst'], $sourceSize, $sourceSha1 );
77 if ( $this->overwriteSameCase ) {
78 $status = StatusValue::newGood();
81 $status = $this->backend->storeInternal( $this->
setFlags( $this->params ) );
88 AtEase::suppressWarnings();
89 $size = filesize( $this->params[
'src'] );
90 AtEase::restoreWarnings();
96 AtEase::suppressWarnings();
97 $hash = sha1_file( $this->params[
'src'] );
98 AtEase::restoreWarnings();
99 if ( $hash !==
false ) {
100 $hash = Wikimedia\base_convert( $hash, 16, 36, 31 );
107 return [ $this->params[
'dst'] ];
FileBackend helper class for representing operations.
precheckDestExistence(FileStatePredicates $opPredicates, $sourceSize, $sourceSha1)
Check for errors with regards to the destination file already existing.
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
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.
Store a file into the backend from a file on the file system.
doPrecheck(FileStatePredicates $opPredicates, FileStatePredicates $batchPredicates)
Do a dry-run precondition check of the operation in the context of op batch.
allowedParams()
Get the file operation parameters.
storagePathsChanged()
Get a list of storage paths written to for this operation.