/** * {@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(); }