/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $size = DB::table('path_records')->sum('size');
     Cache::put('statTotalSize', $size, 60);
     $formatted = DisplaySize::format($size, 2);
     $this->info($formatted);
 }
示例#2
0
 protected function setupStats($view)
 {
     $size = Cache::remember('statTotalSize', 60, function () {
         return DB::table('path_records')->sum('size');
     });
     $formatted = DisplaySize::format($size, 2);
     $view->with('statTotalSize', $formatted);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $dryRun = $this->option('dry-run');
     if (!is_bool($dryRun)) {
         if ($dryRun === 'true') {
             $dryRun = true;
         } elseif ($dryRun === 'false') {
             $dryRun = false;
         } else {
             $this->error($dryRun . ' is not a valid value for --dry-run');
             return;
         }
     }
     $pageSize = 1000;
     $page = 0;
     $count = 0;
     $size = 0;
     while (true) {
         $records = PathRecord::take($pageSize)->offset($page * $pageSize)->get();
         foreach ($records as $record) {
             $path = $record->getPath();
             if (!$path->exists()) {
                 $this->line($record->path);
                 $count++;
                 $size += $record->size;
                 if (!$dryRun) {
                     $record->delete();
                 }
             }
         }
         if ($records->count() < $pageSize) {
             break;
         }
         $page++;
     }
     $this->info(sprintf('%d deleted (%s)', $count, DisplaySize::format($size)));
 }
示例#4
0
 public function getDisplaySize()
 {
     $size = $this->getSize();
     return DisplaySize::format($size);
 }