Skip to content

Commit fd6a438

Browse files
committed
Delete csv and xlsx files only
1 parent 29058fe commit fd6a438

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Commands/DataTablesPurgeExportCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ class DataTablesPurgeExportCommand extends Command
3030
public function handle()
3131
{
3232
$exportPath = config('datatables-export.path', storage_path('app/exports'));
33+
$timestamp = now()->subDay(config('datatables-export.purge.days'))->getTimestamp();
3334

3435
collect(File::allFiles($exportPath))
35-
->each(function (SplFileInfo $file) {
36-
if ($file->getMTime() < now()->subDay(config('datatables-export.purge.days'))->getTimestamp()) {
36+
->each(function (SplFileInfo $file) use ($timestamp) {
37+
if ($file->getMTime() < $timestamp && in_array(strtolower($file->getExtension()), ['xlsx', 'csv'])) {
3738
File::delete($file->getRealPath());
3839
}
3940
});

0 commit comments

Comments
 (0)