Skip to content

Commit 53f564e

Browse files
committed
Fix invalid file path in LocalStorage remove method
1 parent 69465f7 commit 53f564e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Storage/LocalStorage.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,16 @@ public function isStorageAvailable(): bool {
140140
*/
141141
public function hasAttachment(AttachmentInterface $attachment): bool {
142142
$fileName = $this->getAttachmentFileName($attachment);
143-
return file_exists("{$this->absolutePath}/$fileName");
143+
return file_exists("{$this->absolutePath}/{$fileName}");
144144
}
145145

146146
/**
147147
* @param AttachmentInterface $attachment
148148
*/
149149
public function removeAttachment(AttachmentInterface $attachment): void {
150-
if ($this->hasAttachment($attachment)) {
151-
unlink($this->getAttachmentFileName($attachment));
150+
$fileName = $this->getAttachmentFileName($attachment);
151+
if ($fileName !== null && $this->hasAttachment($attachment)) {
152+
unlink("{$this->absolutePath}/{$fileName}");
152153
}
153154
}
154155

0 commit comments

Comments
 (0)