public function handle()
{
if ($this->getOutput()->getVerbosity() > 1) {
$this->intercept();
}
$loop = 0;
try {
while (true) {
$files = $this->storage->paginate(['useCount' => 0, 'parentId' => null], 20);
if (count($files) < 1) {
break;
}
foreach ($files as $file) {
$this->storage->remove($file);
}
sleep(1);
$loop++;
if ($loop > 100) {
throw new \Exception('loop over 100 times');
}
}
$this->info('Done..');
} catch (\Exception $e) {
$this->error('Process error, stopped command');
throw $e;
} finally {
$this->output();
}
}