[FileRepo] Avoiding useless purging for new uploads (not re-uploads).
authorAaron <aschulz@wikimedia.org>
Tue, 22 May 2012 18:36:43 +0000 (11:36 -0700)
committerAaron <aschulz@wikimedia.org>
Tue, 22 May 2012 18:36:43 +0000 (11:36 -0700)
Change-Id: If554c14c786cd5f743c4d8302660a8b1e5295393

includes/filerepo/file/LocalFile.php

index cd8e0c6..3e95b05 100644 (file)
@@ -1055,14 +1055,6 @@ class LocalFile extends File {
                $props['timestamp'] = wfTimestamp( TS_MW, $timestamp ); // DB -> TS_MW
                $this->setProps( $props );
 
-               # Delete thumbnails
-               wfProfileIn( __METHOD__ . '-purge' );
-               $this->purgeThumbnails();
-               wfProfileOut( __METHOD__ . '-purge' );
-
-               # The file is already on its final location, remove it from the squid cache
-               SquidUpdate::purge( array( $this->getURL() ) );
-
                # Fail now if the file isn't there
                if ( !$this->fileExists ) {
                        wfDebug( __METHOD__ . ": File " . $this->getRel() . " went missing!\n" );
@@ -1197,6 +1189,16 @@ class LocalFile extends File {
                # which in fact doesn't really exist (bug 24978)
                $this->saveToCache();
 
+               if ( $reupload ) {
+                       # Delete old thumbnails
+                       wfProfileIn( __METHOD__ . '-purge' );
+                       $this->purgeThumbnails();
+                       wfProfileOut( __METHOD__ . '-purge' );
+
+                       # Remove the old file from the squid cache
+                       SquidUpdate::purge( array( $this->getURL() ) );
+               }
+
                # Hooks, hooks, the magic of hooks...
                wfProfileIn( __METHOD__ . '-hooks' );
                wfRunHooks( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) );