Skip to content

Commit e1ccc00

Browse files
Limon MonteMASNathan
authored andcommitted
Add check if PHP can delete a screenshot (#59)
In my project, I'm writing screenshots to `/tmp` and PHP doesn't have permissions to delete from `/tmp` folder. This additional check is needed to prevent throwing `Warning: unlink(/tmp/screenshot.jpg): Operation not permitted`
1 parent c7f0c2e commit e1ccc00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Capture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function save($imageLocation, $deleteFileIfExists = true)
145145
$data['userAgent'] = $this->userAgentString;
146146
}
147147

148-
if ($deleteFileIfExists && file_exists($outputPath)) {
148+
if ($deleteFileIfExists && file_exists($outputPath) && is_writable($outputPath)) {
149149
unlink($outputPath);
150150
}
151151

0 commit comments

Comments
 (0)