From 339e1ce7d437debeb7195e24f73cb66c3f9705ad Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 4 Jan 2012 08:07:52 +0000 Subject: [PATCH] * Updated rebuildImages.php per r106752. * Also added FIXME about old call to bogus renameFile() function in rebuildImages.php. * Added ContainerShardIterator class from r107980 to autoloader. * Added a few FileBackend comments and improved FileRepo::enumFiles() comments. --- includes/AutoLoader.php | 1 + includes/filerepo/FileRepo.php | 3 ++- includes/filerepo/backend/FileBackend.php | 7 +++++++ maintenance/rebuildImages.php | 24 +++++++---------------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index e805c8cbda..72e9090a40 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -485,6 +485,7 @@ $wgAutoloadLocalClasses = array( 'TempFSFile' => 'includes/filerepo/file/TempFSFile.php', # includes/filerepo/backend + 'ContainerShardListIterator' => 'includes/filerepo/backend/FileBackend.php', 'FileBackendGroup' => 'includes/filerepo/backend/FileBackendGroup.php', 'FileBackendBase' => 'includes/filerepo/backend/FileBackend.php', 'FileBackend' => 'includes/filerepo/backend/FileBackend.php', diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 5b1339d0f5..6592a8a901 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -1214,7 +1214,8 @@ class FileRepo { } /** - * Call a callback function for every public file in the repository. + * Call a callback function for every public regular file in the repository. + * This only acts on the current version of files, not any old versions. * May use either the database or the filesystem. * * @param $callback Array|string diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 71bc5e2c45..5f4cacc0d2 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -318,6 +318,7 @@ abstract class FileBackendBase { /** * Check if a file exists at a storage path in the backend. + * This returns false if only a directory exists at the path. * * $params include: * src : source storage path @@ -489,6 +490,12 @@ abstract class FileBackendBase { /** * Base class for all single-write backends. * This class defines the methods as abstract that subclasses must implement. + * Callers outside of FileBackend and its helper classes, such as FileOp, + * should only call functions that are present in FileBackendBase. + * + * The FileBackendBase operations are implemented using primitive functions + * such as storeInternal(), copyInternal(), deleteInternal() and the like. + * This class is also responsible for path resolution and sanitization. * * @ingroup FileBackend * @since 1.19 diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index 1711183122..d3982881fb 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -148,8 +148,7 @@ class ImageBuilder extends Maintenance { } function buildOldImage() { - $this->buildTable( 'oldimage', 'oi_archive_name', - array( $this, 'oldimageCallback' ) ); + $this->buildTable( 'oldimage', 'oi_archive_name', array( $this, 'oldimageCallback' ) ); } function oldimageCallback( $row, $copy ) { @@ -164,42 +163,33 @@ class ImageBuilder extends Maintenance { } function crawlMissing() { - $repo = RepoGroup::singleton()->getLocalRepo(); - $repo->enumFilesInFS( array( $this, 'checkMissingImage' ) ); + $this->getRepo()->enumFiles( array( $this, 'checkMissingImage' ) ); } function checkMissingImage( $fullpath ) { $filename = wfBaseName( $fullpath ); - if ( is_dir( $fullpath ) ) { - return; - } - if ( is_link( $fullpath ) ) { - $this->output( "skipping symlink at $fullpath\n" ); - return; - } $row = $this->dbw->selectRow( 'image', array( 'img_name' ), array( 'img_name' => $filename ), __METHOD__ ); - if ( $row ) { - // already known, move on - return; - } else { + if ( !$row ) { // file not registered $this->addMissingImage( $filename, $fullpath ); } } function addMissingImage( $filename, $fullpath ) { - $timestamp = $this->dbw->timestamp( filemtime( $fullpath ) ); - global $wgContLang; + + $timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) ); + $altname = $wgContLang->checkTitleEncoding( $filename ); if ( $altname != $filename ) { if ( $this->dryrun ) { $filename = $altname; $this->output( "Estimating transcoding... $altname\n" ); } else { + # @FIXME: create renameFile() $filename = $this->renameFile( $filename ); } } -- 2.20.1