https://www.mediawiki.org/wiki/Special:Code/MediaWiki/109659
Revision: 109659
Author: aaron
Date: 2012-01-20 22:46:35 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
* Added FileBackend::parentStoragePath() convenience function for getting
parent directories.
* In StoreBatchTest: sed proper clean() function to remove temp dirs (follows
up r109641). Also removed some commented out code.
* Fixed temp dir leakage in FileBackendTest.
Modified Paths:
--------------
trunk/phase3/includes/filerepo/backend/FileBackend.php
trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
trunk/phase3/tests/phpunit/includes/filerepo/StoreBatchTest.php
Modified: trunk/phase3/includes/filerepo/backend/FileBackend.php
===================================================================
--- trunk/phase3/includes/filerepo/backend/FileBackend.php 2012-01-20
22:31:28 UTC (rev 109658)
+++ trunk/phase3/includes/filerepo/backend/FileBackend.php 2012-01-20
22:46:35 UTC (rev 109659)
@@ -1245,6 +1245,20 @@
}
/**
+ * 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.
*
Modified: trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
2012-01-20 22:31:28 UTC (rev 109658)
+++ trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
2012-01-20 22:46:35 UTC (rev 109659)
@@ -2,7 +2,6 @@
/**
* @group FileRepo
- * @TODO: fix empty dir leakage
*/
class FileBackendTest extends MediaWikiTestCase {
private $backend, $multiBackend;
@@ -940,6 +939,10 @@
}
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 ) );
+ }
}
}
Modified: trunk/phase3/tests/phpunit/includes/filerepo/StoreBatchTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/filerepo/StoreBatchTest.php
2012-01-20 22:31:28 UTC (rev 109658)
+++ trunk/phase3/tests/phpunit/includes/filerepo/StoreBatchTest.php
2012-01-20 22:46:35 UTC (rev 109659)
@@ -25,26 +25,6 @@
$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',
- '[email protected]',
- array( 'sysop' )
- ),
- 'uploader' => new ApiTestUser(
- 'Uploadstashtestuser',
- 'Upload Stash Test User',
- '[email protected]',
- array()
- )
- );
- **/
}
/**
@@ -116,8 +96,11 @@
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();
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs