/** * {@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; }
/** * @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; }
/** * {@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; }
/** * @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; }
/** * {@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(); }
public function testRemoteListing() { $this->remoteFilesystem->listFiles($this->name)->willReturn([['filename' => 'test-1'], ['filename' => 'test-2']]); $this->assertEquals(['test-1', 'test-2'], $this->storage->remoteListing()); }
public function getChunks($uuid) { $results = $this->filesystem->listFiles($this->prefix . '/' . $uuid); return preg_grep('/^.+\\/(\\d+)_/', $results['keys']); }
/** * @param Filesystem $filesystem * * @return string[] */ protected function listing(Filesystem $filesystem) { return array_filter(array_map(function ($item) { return $item['filename']; }, $filesystem->listFiles($this->name))); }
/** * 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); }
/** * @return array */ public function getListing() { return $this->filesystem->listFiles(); }