Skip to content

Commit

Permalink
Fix issue in BenchmarksModel deleting a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Jul 31, 2024
1 parent 8da4041 commit 8832c38
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/Models/BenchmarksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,17 @@ public function execute(int $id = 0, int $device_id = 0): array
return [];
}

try {
unlink('/usr/local/open-audit/other/ssg-results/' . $device_id . '_' . $id . '_' . $microtime . '_report.html');
} catch (e) {
log_message('error', 'Cannot delete report file from open-audit/other/ssg-results. '. $e);
$this->logCreate($id, $device_id, 'error', 'Cannot delete report file. Error: ' . $e);
if (file_exists('/usr/local/open-audit/other/ssg-results/' . $device_id . '_' . $id . '_' . $microtime . '_report.html')) {
log_message('debug', 'rm command on localhost for ' . $device->attributes->name . ': ' . $parameters->command);
@unlink('/usr/local/open-audit/other/ssg-results/' . $device_id . '_' . $id . '_' . $microtime . '_report.html');
}

if (file_exists('/usr/local/open-audit/other/ssg-results/' . $device_id . '_' . $id . '_' . $microtime . '_report.html')) {
log_message('error', 'Cannot delete report file from open-audit/other/ssg-results.');
$this->logCreate($id, $device_id, 'error', 'Cannot delete report file. /usr/local/open-audit/other/ssg-results/' . $device_id . '_' . $id . '_' . $microtime . '_report.html');
$this->logCreate($id, $device_id, 'info', 'Completed. Memory: ' . round((memory_get_peak_usage(false)/1024/1024), 3) . ' MiB');
return [];
}
log_message('debug', 'rm command on localhost for ' . $device->attributes->name . ': ' . $parameters->command);

$this->logCreate($id, $device_id, 'info', 'Processing report file.');
log_message('debug', 'Processing report file for ' . $device->attributes->name);
Expand Down

0 comments on commit 8832c38

Please sign in to comment.