コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getArchives(JobExecution $jobExecution)
 {
     $directory = dirname($this->getRelativeArchivePath($jobExecution));
     $archives = [];
     foreach ($this->filesystem->listFiles($directory) as $key) {
         $archives[basename($key['path'])] = $key['path'];
     }
     return $archives;
 }
コード例 #2
0
 /**
  * @return array
  */
 public function getFiles()
 {
     if (!$this->files) {
         $this->files = $this->fs->listFiles($this->getDirectory(), true);
         foreach ($this->files as &$file) {
             $this->addData($file);
         }
     }
     return $this->files;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function getFilesList($exclude = false)
 {
     $fileslist = array();
     $files = $this->filesystem->listFiles('', true);
     foreach ($files as $file) {
         $filename = basename($file['path']);
         $dirname = dirname($file['path']);
         $fileslist[$dirname][$filename] = $file['path'];
     }
     return $fileslist;
 }
コード例 #4
0
 /**
  * @return int
  */
 public function pruneStorage()
 {
     if (!$this->options->getPruneMaxCount() && !$this->options->getPruneMaxTtl()) {
         return 0;
     }
     // save to just add
     $this->filesystem->addPlugin(new ListFiles());
     $filesInBackup = $this->filesystem->listFiles($this->options->getPath());
     // filter latest.txt
     if ($this->options->getWriteLatest()) {
         $filesInBackup = array_filter($filesInBackup, function ($item) {
             return $item['basename'] != $this->options->getWriteLatest();
         });
     }
     // sort on timestamp
     usort($filesInBackup, function ($item1, $item2) {
         return strcmp($item1['timestamp'], $item2['timestamp']);
     });
     $pruneCount = 0;
     // remove while count >= pruneMaxCount or timestamp < now - pruneMaxTtl
     while ($last = array_shift($filesInBackup)) {
         if ($this->options->getPruneMaxCount()) {
             if (count($filesInBackup) >= $this->options->getPruneMaxCount()) {
                 $this->filesystem->delete($last['path']);
                 $pruneCount++;
                 continue;
             }
         }
         if ($this->options->getPruneMaxTtl()) {
             if ($last['timestamp'] < time() - $this->options->getPruneMaxTtl()) {
                 $this->filesystem->delete($last['path']);
                 $pruneCount++;
                 continue;
             }
         }
     }
     return $pruneCount;
 }
コード例 #5
0
ファイル: DirectoryPlugin.php プロジェクト: nanbando/core
 /**
  * {@inheritdoc}
  *
  * @throws FileExistsException
  * @throws \InvalidArgumentException
  * @throws FileNotFoundException
  * @throws LogicException
  */
 public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter)
 {
     // TODO make it smoother
     $files = $source->listFiles('', true);
     $progressBar = new ProgressBar($this->output, count($files));
     $progressBar->setOverwrite(true);
     $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
     $progressBar->start();
     foreach ($files as $file) {
         $path = $file['path'];
         $fullPath = $parameter['directory'] . '/' . $file['path'];
         if ($destination->has($fullPath)) {
             if ($destination->hash($fullPath) === $source->hash($path)) {
                 $progressBar->advance();
                 continue;
             }
             $destination->delete($fullPath);
         }
         $destination->writeStream($fullPath, $source->readStream($path));
         $progressBar->advance();
     }
     $progressBar->finish();
 }
コード例 #6
0
ファイル: LocalStorageTest.php プロジェクト: nanbando/core
 public function testRemoteListing()
 {
     $this->remoteFilesystem->listFiles($this->name)->willReturn([['filename' => 'test-1'], ['filename' => 'test-2']]);
     $this->assertEquals(['test-1', 'test-2'], $this->storage->remoteListing());
 }
コード例 #7
0
 public function getChunks($uuid)
 {
     $results = $this->filesystem->listFiles($this->prefix . '/' . $uuid);
     return preg_grep('/^.+\\/(\\d+)_/', $results['keys']);
 }
コード例 #8
0
ファイル: LocalStorage.php プロジェクト: nanbando/core
 /**
  * @param Filesystem $filesystem
  *
  * @return string[]
  */
 protected function listing(Filesystem $filesystem)
 {
     return array_filter(array_map(function ($item) {
         return $item['filename'];
     }, $filesystem->listFiles($this->name)));
 }
コード例 #9
0
ファイル: FlyFilesystem.php プロジェクト: gibboncms/gibbon
 /**
  * List all the files from a directory
  * 
  * @param  string $directory
  * @param  bool $recursive
  * @return array
  */
 public function listFiles($directory = null, $recursive = false)
 {
     return $this->flysystem->listFiles($directory, $recursive);
 }
コード例 #10
0
 /**
  * @return array
  */
 public function getListing()
 {
     return $this->filesystem->listFiles();
 }