From 2283f3e7867fb82583d09b03358972fa55db9176 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 2 Nov 2018 21:16:47 +0100 Subject: [PATCH] Fix #1840 --- app/Http/Controllers/ExportController.php | 2 -- .../ExportJob/ExportJobRepository.php | 33 ------------------- .../ExportJobRepositoryInterface.php | 5 --- 3 files changed, 40 deletions(-) diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 379702255c..5561d7ec07 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -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')); diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index 735e4e45f5..0f2743c515 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -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 */ diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php index d1a35f47a9..89be429ccf 100644 --- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php +++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php @@ -38,11 +38,6 @@ interface ExportJobRepositoryInterface */ public function changeStatus(ExportJob $job, string $status): bool; - /** - * @return bool - */ - public function cleanup(): bool; - /** * @return ExportJob|null */