From ca4ebe3f7bc1fe721f5c4996af3ad68d8e2cc408 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Wed, 7 May 2008 15:03:18 +0000 Subject: [PATCH] * Don't move thumbnails as they are purged anyway * Force regeneration of the hash path * Only switch titles if the move actually succeeded --- includes/filerepo/LocalFile.php | 41 +++++++++++---------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 880cc9b9b8..5528c302a7 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -935,10 +935,16 @@ class LocalFile extends File $this->purgeEverything(); $this->unlock(); - // Now switch the object and repurge - $this->title = $target; - unset( $this->name ); - $this->purgeEverything(); + if ( $status->isOk() ) { + // Now switch the object + $this->title = $target; + // Force regeneration of the name and hashpath + unset( $this->name ); + unset( $this->hashPath ); + // Purge the new image + $this->purgeEverything(); + } + return $status; } @@ -1665,29 +1671,8 @@ class LocalFileMoveBatch { } function addThumbs() { + // Thumbnails are purged, so no need to move them $this->thumbs = array(); - $repo = $this->file->repo; - $thumbDirRel = 'thumb/' . $this->oldRel; - $thumbDir = $repo->getZonePath( 'public' ) . '/' . $thumbDirRel; - $newThumbDirRel = 'thumb/' . $this->newRel; - if( !is_dir( $thumbDir ) || !is_readable( $thumbDir ) ) { - $this->thumbs = array(); - return; - } else { - $files = scandir( $thumbDir ); - foreach( $files as $file ) { - if( $file == '.' || $file == '..' ) continue; - if( preg_match( '/^(\d+)px-/', $file, $matches ) ) { - list( $unused, $width ) = $matches; - $this->thumbs[] = array( - $thumbDirRel . '/' . $file, - $newThumbDirRel . '/' . $width . 'px-' . $this->newName - ); - } else { - wfDebug( 'Strange file in thumbnail directory: ' . $thumbDirRel . '/' . $file ); - } - } - } } function addOlds() { @@ -1713,6 +1698,7 @@ class LocalFileMoveBatch { continue; } $this->oldcount++; + // Do we want to add those to oldcount? if( $row->oi_deleted & File::DELETED_FILE ) { continue; } @@ -1778,8 +1764,9 @@ class LocalFileMoveBatch { // Generates triplets for FSRepo::storeBatch() function getMoveTriplets() { $moves = array_merge( array( $this->cur ), $this->olds, $this->thumbs ); - $triplets = array(); // The format is: (srcUrl,destZone,desrUrl) + $triplets = array(); // The format is: (srcUrl, destZone, destUrl) foreach( $moves as $move ) { + // $move: (oldRelativePath, newRelativePath) $srcUrl = $this->file->repo->getVirtualUrl() . '/public/' . rawurlencode( $move[0] ); $triplets[] = array( $srcUrl, 'public', $move[1] ); } -- 2.20.1