protected function tearDown() { $this->repo->cleanupBatch($this->createdFiles); // delete files foreach ($this->createdFiles as $tmp) { // delete dirs $tmp = $this->repo->resolveVirtualUrl($tmp); while ($tmp = FileBackend::parentStoragePath($tmp)) { $this->repo->getBackend()->clean(array('dir' => $tmp)); } } parent::tearDown(); }
/** * @dataProvider provider_testParentStoragePath */ public function testParentStoragePath($path, $res) { $this->assertEquals($res, FileBackend::parentStoragePath($path), "FileBackend::parentStoragePath on path '{$path}'"); }
/** * Delete the specified files, if they exist. * @param array $files Full paths to files to delete. */ private static function deleteFiles($files) { $backend = RepoGroup::singleton()->getLocalRepo()->getBackend(); foreach ($files as $file) { $backend->delete(array('src' => $file), array('force' => 1)); } foreach ($files as $file) { $tmp = FileBackend::parentStoragePath($file); while ($tmp) { if (!$backend->clean(array('dir' => $tmp))->isOK()) { break; } $tmp = FileBackend::parentStoragePath($tmp); } } }
/** * Delete the specified files and their parent directories * @param array $files File backend URIs mwstore://... */ private function deleteFiles($files) { // Delete the files $backend = RepoGroup::singleton()->getLocalRepo()->getBackend(); foreach ($files as $file) { $backend->delete(['src' => $file], ['force' => 1]); } // Delete the parent directories foreach ($files as $file) { $tmp = FileBackend::parentStoragePath($file); while ($tmp) { if (!$backend->clean(['dir' => $tmp])->isOK()) { break; } $tmp = FileBackend::parentStoragePath($tmp); } } }
private function recursiveClean($dir) { do { if (!$this->backend->clean(array('dir' => $dir))->isOK()) { break; } } while ($dir = FileBackend::parentStoragePath($dir)); }