* Attempt a series of file operations.
* Callers are responsible for handling file locking.
*
+ * $opts is an array of options, including:
+ * 'force' : Errors that would normally cause a rollback do not.
+ * The remaining operations are still attempted if any fail.
+ * 'allowStale' : Don't require the latest available data.
+ * This can increase performance for non-critical writes.
+ * This has no effect unless the 'force' flag is set.
+ *
* @param $performOps Array List of FileOp operations
* @param $opts Array Batch operation options
* @return Status
}
}
+ $wasOk = $status->isOK();
// Finish each operation...
foreach ( $performOps as $index => $fileOp ) {
if ( $fileOp->failed() ) {
}
// Make sure status is OK, despite any finish() fatals
- $status->setResult( true, $status->value );
+ $status->setResult( $wasOk, $status->value );
return $status;
}
$thumb = $this->handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params );
}
} elseif ( $thumb->hasFile() && !$thumb->fileIsSource() ) {
- // Copy the thumbnail from the file system into storage
- // We don't use FileRepo::store() because of hacky suclasses
- // overriding File::getThumbPath() to use a different zone (e.g. 'temp').
- $status = $this->repo->getBackend()->store(
+ $backend = $this->repo->getBackend();
+ // Copy the thumbnail from the file system into storage. This avoids using
+ // FileRepo::store(); getThumbPath() uses a different zone in some subclasses.
+ $backend->prepare( array( 'dir' => dirname( $thumbPath ) ) );
+ $status = $backend->store(
array( 'src' => $tmpThumbPath, 'dst' => $thumbPath ),
array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1 )
);