}
}
+ /**
+ * Get the parent storage directory of a storage path.
+ * This returns a path like "mwstore://backend/container",
+ * "mwstore://backend/container/...", or false if there is no parent.
+ *
+ * @param $storagePath string
+ * @return string|false
+ */
+ final public static function parentStoragePath( $storagePath ) {
+ $storagePath = dirname( $storagePath );
+ list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath );
+ return ( $rel === null ) ? null : $storagePath;
+ }
+
/**
* Check if a given path is a mwstore:// path.
* This does not do any actual validation or existence checks.
/**
* @group FileRepo
- * @TODO: fix empty dir leakage
*/
class FileBackendTest extends MediaWikiTestCase {
private $backend, $multiBackend;
}
foreach ( $this->pathsToPrune as $file ) {
$this->backend->doOperation( array( 'op' => 'delete', 'src' => $file ) );
+ $tmp = $file;
+ while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
+ $this->backend->clean( array( 'dir' => $tmp ) );
+ }
}
}
$this->date = gmdate( "YmdHis" );
$this->createdFiles = array();
-
- // ApiTestUser requires a database connection. Code below does not
- // seem to be needed so it is commented out to not make this test
- // requires a database connection.
- /**
- $this->users = array(
- 'sysop' => new ApiTestUser(
- 'Uploadstashtestsysop',
- 'Upload Stash Test Sysop',
- 'upload_stash_test_sysop@example.com',
- array( 'sysop' )
- ),
- 'uploader' => new ApiTestUser(
- 'Uploadstashtestuser',
- 'Upload Stash Test User',
- 'upload_stash_test_user@example.com',
- array()
- )
- );
- **/
}
/**
public function tearDown() {
$this->repo->cleanupBatch( $this->createdFiles );
- foreach ( array( "temp/0/06", "temp/0", "temp/4/4d", "temp/4", "temp/3/31", "temp/3", "temp", "" ) as $tmp ) {
- rmdir( $this->tmpDir . "/" . $tmp );
+ foreach ( $this->createdFiles as $tmp ) {
+ $tmp = $this->repo->resolveVirtualUrl( $tmp );
+ while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
+ $this->repo->getBackend()->clean( array( 'dir' => $tmp ) );
+ }
}
parent::tearDown();
}