This commit is contained in:
James Cole 2018-11-02 21:16:47 +01:00
parent d261c793ae
commit 2283f3e786
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 0 additions and 40 deletions

View File

@ -118,8 +118,6 @@ class ExportController extends Controller
{
// create new export job.
$job = $jobs->create();
// delete old ones.
$jobs->cleanup();
// does the user have shared accounts?
$formats = array_keys(config('firefly.export_formats'));

View File

@ -64,39 +64,6 @@ class ExportJobRepository implements ExportJobRepositoryInterface
return true;
}
/**
* @return bool
*/
public function cleanup(): bool
{
$dayAgo = Carbon::now()->subDay();
$set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s'))
->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded'])
->get();
$disk = Storage::disk('export');
$files = $disk->files();
// loop set:
/** @var ExportJob $entry */
foreach ($set as $entry) {
$key = $entry->key;
/** @var array $file */
foreach ($files as $file) {
if (0 === strpos($file['basename'], $key)) {
$disk->delete($file['path']);
}
}
try {
$entry->delete();
} catch (Exception $e) {
Log::debug(sprintf('Could not delete object: %s', $e->getMessage()));
}
}
return true;
}
/**
* @return ExportJob|null
*/

View File

@ -38,11 +38,6 @@ interface ExportJobRepositoryInterface
*/
public function changeStatus(ExportJob $job, string $status): bool;
/**
* @return bool
*/
public function cleanup(): bool;
/**
* @return ExportJob|null
*/