Skip to content

Commit 5e2864d

Browse files
tomschlickroshangautam
authored andcommitted
refactor : check the output file exists before trying to use it
1 parent aec858f commit 5e2864d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Events/Executed.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ public function __construct(Task $task, $started)
1919

2020
$time_elapsed_secs = microtime(true) - $started;
2121

22-
$output = file_get_contents(storage_path($task->getMutexName()));
22+
if (file_exists(storage_path($task->getMutexName()))) {
23+
$output = file_get_contents(storage_path($task->getMutexName()));
2324

24-
$task->results()->create([
25-
'duration' => $time_elapsed_secs * 1000,
26-
'result' => $output,
27-
]);
25+
$task->results()->create([
26+
'duration' => $time_elapsed_secs * 1000,
27+
'result' => $output,
28+
]);
2829

29-
unlink(storage_path($task->getMutexName()));
30+
unlink(storage_path($task->getMutexName()));
3031

31-
$task->notify(new TaskCompleted($output));
32+
$task->notify(new TaskCompleted($output));
33+
}
3234
}
3335
}

0 commit comments

Comments
 (0)