Skip to content

Commit 00341d5

Browse files
temppl-github
authored andcommitted
do not throw exception if file is not present (#6)
1 parent 7a7cc06 commit 00341d5

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/Exception/IOException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function createTouchFailed(string $filename): self
2828
return new self("Touch file $filename failed.");
2929
}
3030

31-
public static function createUnlinFailed(string $filename): self
31+
public static function createUnlinkFailed(string $filename): self
3232
{
3333
return new self("Unlink file $filename failed.");
3434
}

src/Storage/FilesystemStorage.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FilesystemStorage implements StorageInterface
3030

3131
public function __construct(string $root)
3232
{
33-
$this->root = $root;
33+
$this->root = rtrim($root, '/');
3434
}
3535

3636
public function write(BlockInterface $block): bool
@@ -67,7 +67,9 @@ public function remove(BlockInterface $block): bool
6767

6868
$filename = $this->getFilename($block->getIdentifier());
6969
if (false === unlink($filename)) {
70-
throw IOException::createUnlinFailed($filename);
70+
if (file_exists($filename)) {
71+
throw IOException::createUnlinkFailed($filename);
72+
}
7173
}
7274

7375
return true;

0 commit comments

Comments
 (0)