ca003c88ba
On S3, index files and the tree segments read back when a snapshot is written are fetched 16 at a time through the storage's S3 client (IBackend::getRanges(), getMany()). Blobs that follow each other in a pack are read as one range on every location. The snapshot is written in a step of its own and the run shows "commit" meanwhile. On a 1 TB production repository the check went from about 4 hours to 3.5 minutes. backup:status and the web interface list the runs of the last 7 days, running ones and at least the newest 5; --all / "Show older runs" list all. Durations of a day or more show the days.
71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
// SPDX-FileCopyrightText: 2026 Dillard Blom
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
namespace OCA\NgBackup\Repository;
|
|
|
|
use OCA\NgBackup\Backend\IBackend;
|
|
|
|
/** The location as Repository sees it: closes the PackReader's open stream before every other request. */
|
|
final class PackReaderGuard implements IBackend {
|
|
public function __construct(
|
|
private IBackend $inner,
|
|
private PackReader $reader,
|
|
) {
|
|
}
|
|
|
|
/** @param resource $stream */
|
|
public function put(string $path, $stream): void {
|
|
$this->reader->close();
|
|
$this->inner->put($path, $stream);
|
|
}
|
|
|
|
public function get(string $path) {
|
|
$this->reader->close();
|
|
return $this->inner->get($path);
|
|
}
|
|
|
|
public function getMany(array $paths): \Generator {
|
|
$this->reader->close();
|
|
return $this->inner->getMany($paths);
|
|
}
|
|
|
|
public function getRange(string $path, int $offset, int $length): string {
|
|
$this->reader->close();
|
|
return $this->inner->getRange($path, $offset, $length);
|
|
}
|
|
|
|
public function getRanges(array $ranges): \Generator {
|
|
$this->reader->close();
|
|
return $this->inner->getRanges($ranges);
|
|
}
|
|
|
|
public function exists(string $path): bool {
|
|
$this->reader->close();
|
|
return $this->inner->exists($path);
|
|
}
|
|
|
|
public function move(string $from, string $to): void {
|
|
$this->reader->close();
|
|
$this->inner->move($from, $to);
|
|
}
|
|
|
|
public function list(string $prefix): array {
|
|
$this->reader->close();
|
|
return $this->inner->list($prefix);
|
|
}
|
|
|
|
public function listFiles(string $dir): array {
|
|
$this->reader->close();
|
|
return $this->inner->listFiles($dir);
|
|
}
|
|
|
|
public function delete(string $path): void {
|
|
$this->reader->close();
|
|
$this->inner->delete($path);
|
|
}
|
|
}
|