Verify: index files several at a time over SFTP, pack folders listed, progress stored and shown
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: 2026 Dillard Blom
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\NgBackup\Backend;
|
||||
|
||||
/** IBackend::getMany() for a backend where reading files one after the other costs nothing extra. */
|
||||
trait GetsOneByOne {
|
||||
/**
|
||||
* @param list<string> $paths
|
||||
* @return \Generator<string, string>
|
||||
*/
|
||||
public function getMany(array $paths): \Generator {
|
||||
foreach ($paths as $path) {
|
||||
$fh = $this->get($path);
|
||||
try {
|
||||
$data = stream_get_contents($fh);
|
||||
} finally {
|
||||
fclose($fh);
|
||||
}
|
||||
if ($data === false) {
|
||||
throw new BackendException('Read failed for ' . $path);
|
||||
}
|
||||
yield $path => $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user