forked from mirror/pixelfed
Update console command
This commit is contained in:
parent
ae4af1675d
commit
85dc4ca0b2
1 changed files with 9 additions and 3 deletions
|
@ -39,12 +39,16 @@ class MediaGarbageCollector extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$gc = Media::whereNull('status_id')
|
||||
->where('created_at', '<', Carbon::now()->subHours(6)->toDateTimeString())
|
||||
$limit = 20000;
|
||||
|
||||
$gc = Media::doesntHave('status')
|
||||
->where('created_at', '<', Carbon::now()->subHours(1)->toDateTimeString())
|
||||
->orderBy('created_at','asc')
|
||||
->take(500)
|
||||
->take($limit)
|
||||
->get();
|
||||
|
||||
$bar = $this->output->createProgressBar($gc->count());
|
||||
$bar->start();
|
||||
foreach($gc as $media) {
|
||||
$path = storage_path("app/$media->media_path");
|
||||
$thumb = storage_path("app/$media->thumbnail_path");
|
||||
|
@ -55,6 +59,8 @@ class MediaGarbageCollector extends Command
|
|||
unlink($thumb);
|
||||
}
|
||||
$media->forceDelete();
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue