Skip to content

Commit

Permalink
capture: re-check if file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
andi34 authored Nov 19, 2023
1 parent fd5d431 commit 7395637
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/PhotoboothCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,28 @@ public function captureWithCmd()
}
}

if (!file_exists($this->tmpFile)) {
$data = [
'error' => 'File was not created',
'cmd' => $cmd,
'returnValue' => $returnValue,
'output' => $output,
];
if ($this->style === 'video') {
// remove all files that were created - all filenames start with the videos name
exec('rm -f ' . $this->tmpFile . '*');
for ($attempt = 1; $attempt <= 3; $attempt++) {
if (file_exists($this->tmpFile)) {
break;
} else {
if ($attempt == 3) {
$data = [
'error' => 'File was not created',
'cmd' => $cmd,
'returnValue' => $returnValue,
'output' => $output,
];
if ($this->style === 'video') {
// remove all files that were created - all filenames start with the videos name
exec('rm -f ' . $this->tmpFile . '*');
}
$this->logger->error('error', $data);
echo json_encode($data);
die();
} else {
sleep(1);
}
}
$this->logger->error('error', $data);
echo json_encode($data);
die();
}
}

Expand Down

0 comments on commit 7395637

Please sign in to comment.