Per comments on r88145: unlink file if it is broken
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 17 Jun 2011 16:48:42 +0000 (16:48 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 17 Jun 2011 16:48:42 +0000 (16:48 +0000)
includes/Import.php

index 3a2c19c..73a15d5 100644 (file)
@@ -1153,6 +1153,10 @@ class WikiRevision {
                }
                $sha1 = $this->getSha1();
                if ( $sha1 && ( $sha1 !== sha1_file( $source ) ) ) {
+                       if ( $flags & File::DELETE_SOURCE ) {
+                               # Broken file; delete it if it is a temporary file
+                               unlink( $source );
+                       }
                        wfDebug( __METHOD__ . ": Corrupt file $source.\n" );
                        return false;
                }