Index: trunk/phase3/tests/phpunit/includes/filerepo/StoreBatchTest.php |
— | — | @@ -25,26 +25,6 @@ |
26 | 26 | |
27 | 27 | $this->date = gmdate( "YmdHis" ); |
28 | 28 | $this->createdFiles = array(); |
29 | | - |
30 | | - // ApiTestUser requires a database connection. Code below does not |
31 | | - // seem to be needed so it is commented out to not make this test |
32 | | - // requires a database connection. |
33 | | - /** |
34 | | - $this->users = array( |
35 | | - 'sysop' => new ApiTestUser( |
36 | | - 'Uploadstashtestsysop', |
37 | | - 'Upload Stash Test Sysop', |
38 | | - 'upload_stash_test_sysop@example.com', |
39 | | - array( 'sysop' ) |
40 | | - ), |
41 | | - 'uploader' => new ApiTestUser( |
42 | | - 'Uploadstashtestuser', |
43 | | - 'Upload Stash Test User', |
44 | | - 'upload_stash_test_user@example.com', |
45 | | - array() |
46 | | - ) |
47 | | - ); |
48 | | - **/ |
49 | 29 | } |
50 | 30 | |
51 | 31 | /** |
— | — | @@ -116,8 +96,11 @@ |
117 | 97 | |
118 | 98 | public function tearDown() { |
119 | 99 | $this->repo->cleanupBatch( $this->createdFiles ); |
120 | | - foreach ( array( "temp/0/06", "temp/0", "temp/4/4d", "temp/4", "temp/3/31", "temp/3", "temp", "" ) as $tmp ) { |
121 | | - rmdir( $this->tmpDir . "/" . $tmp ); |
| 100 | + foreach ( $this->createdFiles as $tmp ) { |
| 101 | + $tmp = $this->repo->resolveVirtualUrl( $tmp ); |
| 102 | + while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) { |
| 103 | + $this->repo->getBackend()->clean( array( 'dir' => $tmp ) ); |
| 104 | + } |
122 | 105 | } |
123 | 106 | parent::tearDown(); |
124 | 107 | } |
Index: trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php |
— | — | @@ -2,7 +2,6 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * @group FileRepo |
6 | | - * @TODO: fix empty dir leakage |
7 | 6 | */ |
8 | 7 | class FileBackendTest extends MediaWikiTestCase { |
9 | 8 | private $backend, $multiBackend; |
— | — | @@ -940,6 +939,10 @@ |
941 | 940 | } |
942 | 941 | foreach ( $this->pathsToPrune as $file ) { |
943 | 942 | $this->backend->doOperation( array( 'op' => 'delete', 'src' => $file ) ); |
| 943 | + $tmp = $file; |
| 944 | + while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) { |
| 945 | + $this->backend->clean( array( 'dir' => $tmp ) ); |
| 946 | + } |
944 | 947 | } |
945 | 948 | } |
946 | 949 | |
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -1245,6 +1245,20 @@ |
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | /** |
| 1249 | + * Get the parent storage directory of a storage path. |
| 1250 | + * This returns a path like "mwstore://backend/container", |
| 1251 | + * "mwstore://backend/container/...", or false if there is no parent. |
| 1252 | + * |
| 1253 | + * @param $storagePath string |
| 1254 | + * @return string|false |
| 1255 | + */ |
| 1256 | + final public static function parentStoragePath( $storagePath ) { |
| 1257 | + $storagePath = dirname( $storagePath ); |
| 1258 | + list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath ); |
| 1259 | + return ( $rel === null ) ? null : $storagePath; |
| 1260 | + } |
| 1261 | + |
| 1262 | + /** |
1249 | 1263 | * Check if a given path is a mwstore:// path. |
1250 | 1264 | * This does not do any actual validation or existence checks. |
1251 | 1265 | * |