b06ff0f89f
ExternalStorageFactory builds storages with files_external's own backends and auth mechanisms from an unsaved StorageConfig (as its ConfigAdapter does), and StorageBackend adapts any IStorage to IBackend (writeStream, seekable range reads, temp name + rename except on S3). IBackend::put() now owns and always closes the stream, because files_external's S3 writeStream closes it. Spike D (NC34): S3 (SeaweedFS) and SFTP: 120 MiB backup ~6s, unchanged run uploads nothing, restore bit-identical, no files_external mount created, no temp files (max 12 KiB in /tmp). Works with files_external disabled when its classes are loaded. Backup peak memory 85-89 MiB on these targets (to investigate).
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
// SPDX-FileCopyrightText: 2026 Dillard Blom
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
namespace OCA\NgBackup\Backend;
|
|
|
|
/**
|
|
* Minimal object store used by the repository. Paths are relative, '/'-separated.
|
|
* Implementations: a local directory (spike, tests), and adapters over files_external storages.
|
|
*/
|
|
interface IBackend {
|
|
/**
|
|
* Store an object; the stream is read to EOF. Takes ownership of the stream: it is always
|
|
* closed afterwards (some storages, like files_external's S3, close it themselves).
|
|
* Must not leave a partial object behind on failure.
|
|
*/
|
|
public function put(string $path, $stream): void;
|
|
|
|
/** @return resource readable stream of the whole object */
|
|
public function get(string $path);
|
|
|
|
/** @return string bytes [$offset, $offset + $length) of the object (used to fetch single blobs from a pack) */
|
|
public function getRange(string $path, int $offset, int $length): string;
|
|
|
|
public function exists(string $path): bool;
|
|
|
|
/** @return list<string> object paths below $prefix (recursive) */
|
|
public function list(string $prefix): array;
|
|
|
|
public function delete(string $path): void;
|
|
}
|