Exemple #1
0
 private function cleanupChunks()
 {
     foreach ($this->filesystem->directories($this->temporaryChunksFolder) as $file) {
         if (time() - $this->filesystem->lastModified($file) > $this->chunksExpireIn) {
             $this->filesystem->deleteDirectory($file);
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->option('filter')) {
         $this->filesystem->deleteDirectory(config('image-service.path') . '/' . $this->option('filter'));
         $this->info('Deleted all cached images for "' . $this->option('filter') . '" filter.');
     } elseif ($this->option('cached')) {
         foreach ($this->filesystem->directories(config('image-service.path')) as $dir) {
             // don't delete the original source image
             if (!preg_match("/original\$/mi", $dir)) {
                 $this->filesystem->deleteDirectory($dir);
             }
         }
         $this->info('Deleted all cached images.');
     } else {
         $this->filesystem->deleteDirectory(config('image-service.path'));
         $this->info('All images has been deleted.');
     }
 }
 /**
  * @param Filesystem $filesystem
  * @param Repository $config
  * @return CommandResult
  */
 public function handle(Filesystem $filesystem, Repository $config)
 {
     $path = is_null($this->path) ? DIRECTORY_SEPARATOR : $this->path;
     $response = [];
     $response['files'] = $filesystem->files($path);
     $response['directories'] = $filesystem->directories($path);
     $response['base_path'] = $config->get('filesystems.disks.local.root');
     $response['paths'] = $this->breakDownPath($path);
     $response['current_path'] = $this->path;
     $response['is_empty'] = $this->isResultIsEmpty($response['files'], $response['directories']);
     // all good
     return new CommandResult(true, "List command successful.", $response, 200);
 }
 /**
  * Execute the console command.
  *
  * @return int
  */
 public function handle(Filesystem $fs)
 {
     if ($this->option('all') && strlen($this->argument('name')) > 0) {
         $this->error('--all and <name> are mutually exclusive command options. Cannot run.');
         return 1;
     }
     if ($this->argument('name') && $fs->exists("providers/scrapers/{$this->argument('name')}")) {
         $this->scheduleScraperRun($this->argument('name'));
     } else {
         $scrapers = collect($fs->directories('providers/scrapers'))->map(function ($dirName) {
             return str_replace('providers/scrapers/', '', $dirName);
         });
         if ($this->option('all') || $scrapers->count() < self::JOBS_PER_CALL) {
             $this->scheduleScrapers($scrapers);
         } else {
             $this->processChunk($fs, $scrapers);
         }
     }
     return 0;
 }
Exemple #5
0
 /**
  * Get all of the directories within a given directory.
  *
  * @param  string|null $directory
  * @param  bool $recursive
  *
  * @return array
  */
 public function directories($directory = null, $recursive = false)
 {
     $directory = $this->getPathPrefix($directory);
     return $this->drive->directories($directory, $recursive);
 }
Exemple #6
0
 /**
  * Scan the directory.
  *
  * @param string $dir
  * @return \Illuminate\Support\Collection
  */
 protected function scanDirectory($dir)
 {
     return collect($this->storage->directories($dir));
 }