Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  We need access to the parent dir to delete files.
  • Loading branch information
Jelle-S committed Mar 3, 2017
2 parents d18c70c + f04ea21 commit e29558c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/PartialCleanDirs.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ protected function cleanDir($dir, $keep)
}
foreach ($items as $item) {
try {
// To delete a file we must have access rights on the parent
// directory.
$this->fs->chmod(dirname(realpath($item)), 0777, 0000, true);
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work, try to remove anyway.
Expand Down
60 changes: 30 additions & 30 deletions tests/PartialCleanDirsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,98 +74,98 @@ public function testRun() {
$fs = $this->getMockBuilder(\Symfony\Component\Filesystem\Filesystem::class)
->getMock();

$fs->expects($this->at(0))
$fs->expects($this->at(1))
->method('chmod')
->with('dir1', 0777, 0000, true);
$fs->expects($this->at(1))
$fs->expects($this->at(2))
->method('remove')
->with('dir1');
$fs->expects($this->at(2))
$fs->expects($this->at(4))
->method('chmod')
->with('dir2', 0777, 0000, true);
$fs->expects($this->at(3))
$fs->expects($this->at(5))
->method('remove')
->with('dir2');
$fs->expects($this->at(4))
$fs->expects($this->at(7))
->method('chmod')
->with('dir3', 0777, 0000, true);
$fs->expects($this->at(5))
$fs->expects($this->at(8))
->method('remove')
->with('dir3');
$fs->expects($this->at(6))
$fs->expects($this->at(10))
->method('chmod')
->with('dir4', 0777, 0000, true);
$fs->expects($this->at(7))
$fs->expects($this->at(11))
->method('remove')
->with('dir4');
$fs->expects($this->at(8))
$fs->expects($this->at(13))
->method('chmod')
->with('dir5', 0777, 0000, true);
$fs->expects($this->at(9))
$fs->expects($this->at(14))
->method('remove')
->with('dir5');
$fs->expects($this->at(10))
$fs->expects($this->at(16))
->method('chmod')
->with('dir6', 0777, 0000, true);
$fs->expects($this->at(11))
$fs->expects($this->at(17))
->method('remove')
->with('dir6');

// Delete items in path/to/dir2.
$fs->expects($this->at(12))
$fs->expects($this->at(19))
->method('chmod')
->with('dir1', 0777, 0000, true);
$fs->expects($this->at(13))
$fs->expects($this->at(20))
->method('remove')
->with('dir1');
$fs->expects($this->at(14))
$fs->expects($this->at(22))
->method('chmod')
->with('dir2', 0777, 0000, true);
$fs->expects($this->at(15))
$fs->expects($this->at(23))
->method('remove')
->with('dir2');
$fs->expects($this->at(16))
$fs->expects($this->at(25))
->method('chmod')
->with('dir3', 0777, 0000, true);
$fs->expects($this->at(17))
$fs->expects($this->at(26))
->method('remove')
->with('dir3');
$fs->expects($this->at(18))
$fs->expects($this->at(28))
->method('chmod')
->with('dir4', 0777, 0000, true);
$fs->expects($this->at(19))
$fs->expects($this->at(29))
->method('remove')
->with('dir4');
$fs->expects($this->at(20))
$fs->expects($this->at(31))
->method('chmod')
->with('dir5', 0777, 0000, true);
$fs->expects($this->at(21))
$fs->expects($this->at(32))
->method('remove')
->with('dir5');
$fs->expects($this->at(22))
$fs->expects($this->at(34))
->method('chmod')
->with('dir6', 0777, 0000, true);
$fs->expects($this->at(23))
$fs->expects($this->at(35))
->method('remove')
->with('dir6');
$fs->expects($this->at(24))
$fs->expects($this->at(37))
->method('chmod')
->with('dir7', 0777, 0000, true);
$fs->expects($this->at(25))
$fs->expects($this->at(38))
->method('remove')
->with('dir7');
$fs->expects($this->at(26))
$fs->expects($this->at(40))
->method('chmod')
->with('dir8', 0777, 0000, true);
$fs->expects($this->at(27))
$fs->expects($this->at(41))
->method('remove')
->with('dir8');

// Delete items in path/to/dir3.
$fs->expects($this->at(28))
$fs->expects($this->at(43))
->method('chmod')
->with('dir1', 0777, 0000, true);
$fs->expects($this->at(29))
$fs->expects($this->at(44))
->method('remove')
->with('dir1');

Expand Down

0 comments on commit e29558c

Please sign in to comment.