From e59b00c85bee0c15cdef65fe7204789543f2cd9a Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Fri, 2 Oct 2009 10:13:21 +0000 Subject: [PATCH] importImages --skip-dupes checks for dupes using sha1 --- maintenance/importImages.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/maintenance/importImages.php b/maintenance/importImages.php index c41bfa650f..a85b8bd995 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -124,6 +124,19 @@ if (isset($options['protect']) && $options['protect'] == 1) continue; } } else { + if ( isset( $options['skip-dupes'] ) ) { + $repo = $image->getRepo(); + $sha1 = File::sha1Base36( $file ); #XXX: we end up calculating this again when actually uploading. that sucks. + + $dupes = $repo->findBySha1( $sha1 ); + + if ( $dupes ) { + echo( "{$base} already exists as " . $dupes[0]->getName() . ", skipping\n" ); + $skipped++; + continue; + } + } + echo( "Importing {$base}..." ); $svar = 'added'; } @@ -253,6 +266,7 @@ Options: --limit= Limit the number of images to process. Ignored or skipped images are not counted. --from= Ignore all files until the one with the given name. Useful for resuming aborted imports. should be the file's canonical database form. +--skip-dupes Skip images that were already uploaded under a different name (check SHA1) --sleep= Sleep between files. Useful mostly for debugging. --user= Set username of uploader, default 'Maintenance script' --check-userblock Check if the user got blocked during import. -- 2.20.1