Index: trunk/phase3/maintenance/importImages.php |
— | — | @@ -124,6 +124,19 @@ |
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | } else { |
| 128 | + if ( isset( $options['skip-dupes'] ) ) { |
| 129 | + $repo = $image->getRepo(); |
| 130 | + $sha1 = File::sha1Base36( $file ); #XXX: we end up calculating this again when actually uploading. that sucks. |
| 131 | + |
| 132 | + $dupes = $repo->findBySha1( $sha1 ); |
| 133 | + |
| 134 | + if ( $dupes ) { |
| 135 | + echo( "{$base} already exists as " . $dupes[0]->getName() . ", skipping\n" ); |
| 136 | + $skipped++; |
| 137 | + continue; |
| 138 | + } |
| 139 | + } |
| 140 | + |
128 | 141 | echo( "Importing {$base}..." ); |
129 | 142 | $svar = 'added'; |
130 | 143 | } |
— | — | @@ -253,6 +266,7 @@ |
254 | 267 | --limit=<num> Limit the number of images to process. Ignored or skipped images are not counted. |
255 | 268 | --from=<name> Ignore all files until the one with the given name. Useful for resuming |
256 | 269 | aborted imports. <name> should be the file's canonical database form. |
| 270 | +--skip-dupes Skip images that were already uploaded under a different name (check SHA1) |
257 | 271 | --sleep=<sec> Sleep between files. Useful mostly for debugging. |
258 | 272 | --user=<username> Set username of uploader, default 'Maintenance script' |
259 | 273 | --check-userblock Check if the user got blocked during import. |