mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 09:21:04 -06:00
Fix #1840
This commit is contained in:
parent
d261c793ae
commit
2283f3e786
@ -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'));
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -38,11 +38,6 @@ interface ExportJobRepositoryInterface
|
||||
*/
|
||||
public function changeStatus(ExportJob $job, string $status): bool;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanup(): bool;
|
||||
|
||||
/**
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user