// Purge any custom thumbnail caches
Hooks::run( 'LocalFilePurgeThumbnails', [ $this, $archiveName ] );
+ // Delete thumbnails
$dir = array_shift( $files );
$this->purgeThumbList( $dir, $files );
* @param array $options
*/
public function purgeThumbnails( $options = [] ) {
- // Delete thumbnails
$files = $this->getThumbnails();
// Always purge all files from CDN regardless of handler filters
$urls = [];
// Purge any custom thumbnail caches
Hooks::run( 'LocalFilePurgeThumbnails', [ $this, false ] );
+ // Delete thumbnails
$dir = array_shift( $files );
$this->purgeThumbList( $dir, $files );
/**
* Upload a file and record it in the DB
- * @param string $srcPath Source storage path, virtual URL, or filesystem path
+ * @param string|FSFile $src Source storage path, virtual URL, or filesystem path
* @param string $comment Upload description
* @param string $pageText Text to use for the new description page,
* if a new description page is created
* @return FileRepoStatus On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
- function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,
+ function upload( $src, $comment, $pageText, $flags = 0, $props = false,
$timestamp = false, $user = null, $tags = []
) {
global $wgContLang;
return $this->readOnlyFatalStatus();
}
+ $srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src;
if ( !$props ) {
if ( $this->repo->isVirtualUrl( $srcPath )
|| FileBackend::isStoragePath( $srcPath )
// non-nicely (dangling multi-byte chars, non-truncated version in cache).
$comment = $wgContLang->truncate( $comment, 255 );
$this->lock(); // begin
- $status = $this->publish( $srcPath, $flags, $options );
+ $status = $this->publish( $src, $flags, $options );
if ( $status->successCount >= 2 ) {
// There will be a copy+(one of move,copy,store).
* The archive name should be passed through to recordUpload for database
* registration.
*
- * @param string $srcPath Local filesystem path or virtual URL to the source image
+ * @param string|FSFile $src Local filesystem path or virtual URL to the source image
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @param array $options Optional additional parameters
* @return FileRepoStatus On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
- function publish( $srcPath, $flags = 0, array $options = [] ) {
- return $this->publishTo( $srcPath, $this->getRel(), $flags, $options );
+ function publish( $src, $flags = 0, array $options = [] ) {
+ return $this->publishTo( $src, $this->getRel(), $flags, $options );
}
/**
* The archive name should be passed through to recordUpload for database
* registration.
*
- * @param string $srcPath Local filesystem path or virtual URL to the source image
+ * @param string|FSFile $src Local filesystem path or virtual URL to the source image
* @param string $dstRel Target relative path
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @return FileRepoStatus On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
- function publishTo( $srcPath, $dstRel, $flags = 0, array $options = [] ) {
+ function publishTo( $src, $dstRel, $flags = 0, array $options = [] ) {
+ $srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src;
+
$repo = $this->getRepo();
if ( $repo->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
if ( $repo->hasSha1Storage() ) {
$sha1 = $repo->isVirtualUrl( $srcPath )
? $repo->getFileSha1( $srcPath )
- : File::sha1Base36( $srcPath );
+ : FSFile::getSha1Base36FromPath( $srcPath );
$dst = $repo->getBackend()->getPathForSHA1( $sha1 );
- $status = $repo->quickImport( $srcPath, $dst );
+ $status = $repo->quickImport( $src, $dst );
if ( $flags & File::DELETE_SOURCE ) {
unlink( $srcPath );
}
$this->newName = $this->file->repo->getNameFromTitle( $this->target );
$this->oldRel = $this->oldHash . $this->oldName;
$this->newRel = $this->newHash . $this->newName;
- $this->db = $file->getRepo()->getMasterDb();
+ $this->db = $file->getRepo()->getMasterDB();
}
/**