Per comments on r88145: unlink file if it is broken
[lhc/web/wiklou.git] / includes / Import.php
index 1e6df49..73a15d5 100644 (file)
@@ -39,7 +39,7 @@ class WikiImporter {
 
        /**
         * Creates an ImportXMLReader drawing from the source provided
-       */
+        */
        function __construct( $source ) {
                $this->reader = new XMLReader();
 
@@ -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;
                }