Reject empty SQLite backup artifacts during verification
ABSDEV Framework CI / framework-ci (push) Successful in 25s

This commit is contained in:
Mark Gregory
2026-11-27 18:01:12 +00:00
parent 5ce5781b08
commit a6daf917ad
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -84,6 +84,8 @@ class SandboxDatabase:
if db.execute("PRAGMA integrity_check").fetchall() != [("ok",)]:
raise DatabaseIdentityError("Backup integrity check failed")
digest, size = checksum(path)
if size == 0:
raise DatabaseIdentityError("SQLite backup is empty")
result = {
"backup_id": identifier, "driver": "sqlite", "database": "acceptance",
"username": "local_fixture", "container": "local_fixture",
+13
View File
@@ -1,6 +1,7 @@
import sqlite3
import tempfile
import unittest
import uuid
from contextlib import closing
from pathlib import Path
@@ -26,3 +27,15 @@ class DatabaseTests(unittest.TestCase):
db.path.touch(mode=0o600)
with self.assertRaises(DatabaseIdentityError):
db.check()
def test_rejects_empty_backup_left_after_interruption(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory).resolve()
db = SandboxDatabase(root)
identifier = uuid.uuid4().hex
backup = root / identifier
backup.mkdir(mode=0o700)
path = backup / "database.sqlite"
path.touch(mode=0o600)
with self.assertRaisesRegex(DatabaseIdentityError, "SQLite backup is empty"):
db.verify(identifier)