mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 17:53:16 +00:00
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()
|
public function handle()
|
||||||
{
|
{
|
||||||
$gc = Media::whereNull('status_id')
|
$limit = 20000;
|
||||||
->where('created_at', '<', Carbon::now()->subHours(6)->toDateTimeString())
|
|
||||||
|
$gc = Media::doesntHave('status')
|
||||||
|
->where('created_at', '<', Carbon::now()->subHours(1)->toDateTimeString())
|
||||||
->orderBy('created_at','asc')
|
->orderBy('created_at','asc')
|
||||||
->take(500)
|
->take($limit)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$bar = $this->output->createProgressBar($gc->count());
|
||||||
|
$bar->start();
|
||||||
foreach($gc as $media) {
|
foreach($gc as $media) {
|
||||||
$path = storage_path("app/$media->media_path");
|
$path = storage_path("app/$media->media_path");
|
||||||
$thumb = storage_path("app/$media->thumbnail_path");
|
$thumb = storage_path("app/$media->thumbnail_path");
|
||||||
|
@ -55,6 +59,8 @@ class MediaGarbageCollector extends Command
|
||||||
unlink($thumb);
|
unlink($thumb);
|
||||||
}
|
}
|
||||||
$media->forceDelete();
|
$media->forceDelete();
|
||||||
|
$bar->advance();
|
||||||
}
|
}
|
||||||
|
$bar->finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue