Run the backup job at every cron run; skip deflate on compressed data

This commit is contained in:
2026-10-15 20:59:04 +02:00
parent 5b7dd08e71
commit 144097d159
4 changed files with 47 additions and 2 deletions
+14
View File
@@ -66,6 +66,20 @@ class RepositoryTest extends TestCase {
$this->assertSame(1, $r2['newBlobs']);
}
public function testCompressedDataSkipsDeflateAndOtherDataIsStillCompressed(): void {
$repo = Repository::init($this->backend, 'pw');
$text = str_repeat("a line of a log file, much like the one before\n", 30000); // ~1.4 MiB
$noise = random_bytes(1048576); // like a photo: deflate saves nothing
$stats = [];
$textId = $repo->storeData($text, $stats);
$textUploaded = $stats['uploaded'];
$noiseId = $repo->storeData($noise, $stats);
$repo->flushPacks();
$this->assertLessThan(strlen($text) / 10, $textUploaded);
$this->assertLessThan(strlen($noise) + 1024, $stats['uploaded'] - $textUploaded);
$this->assertSame($text . $noise, implode('', iterator_to_array(Repository::open($this->backend, 'pw')->readBlobs([$textId, $noiseId]), false)));
}
public function testPartialRestore(): void {
$repo = Repository::init($this->backend, 'pw');
$r = $repo->backupDirectory($this->src);