mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Also delete old files.
This commit is contained in:
		| @@ -28,9 +28,24 @@ class ExportJobRepository implements ExportJobRepositoryInterface | ||||
|     public function cleanup() | ||||
|     { | ||||
|         $dayAgo = Carbon::create()->subDay(); | ||||
|         ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) | ||||
|                  ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) | ||||
|                  ->delete(); | ||||
|         $set    = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) | ||||
|                            ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) | ||||
|                            ->get(); | ||||
|  | ||||
|         // loop set: | ||||
|         /** @var ExportJob $entry */ | ||||
|         foreach ($set as $entry) { | ||||
|             $key   = $entry->key; | ||||
|             $len   = strlen($key); | ||||
|             $files = scandir(storage_path('export')); | ||||
|             /** @var string $file */ | ||||
|             foreach ($files as $file) { | ||||
|                 if (substr($file, 0, $len) === $key) { | ||||
|                     unlink(storage_path('export') . DIRECTORY_SEPARATOR . $file); | ||||
|                 } | ||||
|             } | ||||
|             $entry->delete(); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user