From ba1f10470172218750edf4868f6a273f87654e43 Mon Sep 17 00:00:00 2001 From: Aaron Date: Wed, 25 Apr 2012 10:47:59 -0700 Subject: [PATCH] Split out quickCleanDir() function just for thumbnails for consistency. Change-Id: I02f3eefc703016ac5681128de05ff09e716646d1 --- includes/filerepo/FileRepo.php | 18 +++++++++++++++++- includes/filerepo/file/ForeignAPIFile.php | 2 +- includes/filerepo/file/LocalFile.php | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 35c3508dc6..196c9de004 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -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 ) ) ) ); diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index 9ae501a43d..80144132a0 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -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 ); } } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index ffadca9f20..701a1ec2a3 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 */ -- 2.20.1