r107991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107990‎ | r107991 | r107992 >
Date:08:07, 4 January 2012
Author:aaron
Status:ok
Tags:
Comment:
* 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.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildImages.php
@@ -148,8 +148,7 @@
149149 }
150150
151151 function buildOldImage() {
152 - $this->buildTable( 'oldimage', 'oi_archive_name',
153 - array( $this, 'oldimageCallback' ) );
 152+ $this->buildTable( 'oldimage', 'oi_archive_name', array( $this, 'oldimageCallback' ) );
154153 }
155154
156155 function oldimageCallback( $row, $copy ) {
@@ -164,42 +163,33 @@
165164 }
166165
167166 function crawlMissing() {
168 - $repo = RepoGroup::singleton()->getLocalRepo();
169 - $repo->enumFilesInFS( array( $this, 'checkMissingImage' ) );
 167+ $this->getRepo()->enumFiles( array( $this, 'checkMissingImage' ) );
170168 }
171169
172170 function checkMissingImage( $fullpath ) {
173171 $filename = wfBaseName( $fullpath );
174 - if ( is_dir( $fullpath ) ) {
175 - return;
176 - }
177 - if ( is_link( $fullpath ) ) {
178 - $this->output( "skipping symlink at $fullpath\n" );
179 - return;
180 - }
181172 $row = $this->dbw->selectRow( 'image',
182173 array( 'img_name' ),
183174 array( 'img_name' => $filename ),
184175 __METHOD__ );
185176
186 - if ( $row ) {
187 - // already known, move on
188 - return;
189 - } else {
 177+ if ( !$row ) { // file not registered
190178 $this->addMissingImage( $filename, $fullpath );
191179 }
192180 }
193181
194182 function addMissingImage( $filename, $fullpath ) {
195 - $timestamp = $this->dbw->timestamp( filemtime( $fullpath ) );
196 -
197183 global $wgContLang;
 184+
 185+ $timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) );
 186+
198187 $altname = $wgContLang->checkTitleEncoding( $filename );
199188 if ( $altname != $filename ) {
200189 if ( $this->dryrun ) {
201190 $filename = $altname;
202191 $this->output( "Estimating transcoding... $altname\n" );
203192 } else {
 193+ # @FIXME: create renameFile()
204194 $filename = $this->renameFile( $filename );
205195 }
206196 }
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php
@@ -318,6 +318,7 @@
319319
320320 /**
321321 * Check if a file exists at a storage path in the backend.
 322+ * This returns false if only a directory exists at the path.
322323 *
323324 * $params include:
324325 * src : source storage path
@@ -489,7 +490,13 @@
490491 /**
491492 * Base class for all single-write backends.
492493 * This class defines the methods as abstract that subclasses must implement.
 494+ * Callers outside of FileBackend and its helper classes, such as FileOp,
 495+ * should only call functions that are present in FileBackendBase.
493496 *
 497+ * The FileBackendBase operations are implemented using primitive functions
 498+ * such as storeInternal(), copyInternal(), deleteInternal() and the like.
 499+ * This class is also responsible for path resolution and sanitization.
 500+ *
494501 * @ingroup FileBackend
495502 * @since 1.19
496503 */
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -1214,7 +1214,8 @@
12151215 }
12161216
12171217 /**
1218 - * Call a callback function for every public file in the repository.
 1218+ * Call a callback function for every public regular file in the repository.
 1219+ * This only acts on the current version of files, not any old versions.
12191220 * May use either the database or the filesystem.
12201221 *
12211222 * @param $callback Array|string
Index: trunk/phase3/includes/AutoLoader.php
@@ -485,6 +485,7 @@
486486 'TempFSFile' => 'includes/filerepo/file/TempFSFile.php',
487487
488488 # includes/filerepo/backend
 489+ 'ContainerShardListIterator' => 'includes/filerepo/backend/FileBackend.php',
489490 'FileBackendGroup' => 'includes/filerepo/backend/FileBackendGroup.php',
490491 'FileBackendBase' => 'includes/filerepo/backend/FileBackend.php',
491492 'FileBackend' => 'includes/filerepo/backend/FileBackend.php',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106752Merged FileBackend branch. Manually avoiding merging the many prop-only chang...aaron03:52, 20 December 2011
r107980* Added supported for container sharding via existing FileRepo-style hash pat...aaron01:08, 4 January 2012

Status & tagging log