Merge "'lang' attrib in #mw-content-text should be set to variant code."
[lhc/web/wiklou.git] / maintenance / deleteArchivedFiles.inc
index bcbdbc1..e638b17 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  */
 
+/**
+ * Core functions for deleteArchivedFiles.php
+ *
+ * @ingroup Maintenance
+ */
 class DeleteArchivedFilesImplementation {
        static public function doDelete( $output, $force ) {
                # Data should come off the master, wrapped in a transaction
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->begin();
+               $dbw->begin( __METHOD__ );
                $tbl_arch = $dbw->tableName( 'filearchive' );
                $repo = RepoGroup::singleton()->getLocalRepo();
                # Get "active" revisions from the filearchive table
@@ -44,19 +50,22 @@ class DeleteArchivedFilesImplementation {
                                __METHOD__,
                                array( 'FOR UPDATE' )
                        );
-                       if ( $path && file_exists( $path ) && !$inuse ) {
-                               unlink( $path ); // delete
-                               $count++;
-                               $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
+                       if ( $path && $repo->fileExists( $path ) && !$inuse ) {
+                               if ( $repo->quickPurge( $path ) ) {
+                                       $count++;
+                                       $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
+                               } else {
+                                       $output->handleOutput( "Unable to remove file $path, skipping\n" );
+                               }
                        } else {
                                $output->handleOutput( "Notice - file '$key' not found in group '$group'\n" );
                                if ( $force ) {
-                                       $outpu->handleOutput( "Got --force, deleting DB entry\n" );
+                                       $output->handleOutput( "Got --force, deleting DB entry\n" );
                                        $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
                                }
                        }
                }
-               $dbw->commit();
+               $dbw->commit( __METHOD__ );
                $output->handleOutput( "Done! [$count file(s)]\n" );
        }
-}
\ No newline at end of file
+}