Split out quickCleanDir() function just for thumbnails for consistency.
authorAaron <aschulz@wikimedia.org>
Wed, 25 Apr 2012 17:47:59 +0000 (10:47 -0700)
committerAaron <aschulz@wikimedia.org>
Wed, 25 Apr 2012 17:47:59 +0000 (10:47 -0700)
Change-Id: I02f3eefc703016ac5681128de05ff09e716646d1

includes/filerepo/FileRepo.php
includes/filerepo/file/ForeignAPIFile.php
includes/filerepo/file/LocalFile.php

index 35c3508..196c9de 100644 (file)
@@ -805,6 +805,21 @@ class FileRepo {
                return $this->quickPurgeBatch( array( $path ) );
        }
 
+       /**
+        * Deletes a directory if empty.
+        * This function can be used to write to otherwise read-only foreign repos.
+        *
+        * @param $dir string Virtual URL (or storage path) of directory to clean
+        * @return Status
+        */
+       public function quickCleanDir( $dir ) {
+               $status = $this->newGood();
+               $status->merge( $this->backend->clean(
+                       array( 'dir' => $this->resolveToStoragePath( $dir ) ) ) );
+
+               return $status;
+       }
+
        /**
         * Import a batch of files from the local file system into the repo.
         * This does no locking nor journaling and overrides existing files.
@@ -1088,12 +1103,13 @@ class FileRepo {
 
        /**
         * Deletes a directory if empty.
-        * This function can be used to write to otherwise read-only foreign repos.
         *
         * @param $dir string Virtual URL (or storage path) of directory to clean
         * @return Status
         */
        public function cleanDir( $dir ) {
+               $this->assertWritableRepo(); // fail out if read-only
+
                $status = $this->newGood();
                $status->merge( $this->backend->clean(
                        array( 'dir' => $this->resolveToStoragePath( $dir ) ) ) );
index 9ae501a..8014413 100644 (file)
@@ -249,6 +249,6 @@ class ForeignAPIFile extends File {
                # Delete the thumbnails
                $this->repo->quickPurgeBatch( $purgeList );
                # Clear out the thumbnail directory if empty
-               $this->repo->cleanDir( $dir );
+               $this->repo->quickCleanDir( $dir );
        }
 }
index ffadca9..701a1ec 100644 (file)
@@ -779,7 +779,7 @@ class LocalFile extends File {
                # Delete the thumbnails
                $this->repo->quickPurgeBatch( $purgeList );
                # Clear out the thumbnail directory if empty
-               $this->repo->cleanDir( $dir );
+               $this->repo->quickCleanDir( $dir );
        }
 
        /** purgeDescription inherited */