fix(backup): fix 7 bugs in backup/restore — strip-components, multi-db path, verify+log in HTTP handler, parseBackupFilename for .tar, getArchiveSize gzip -l, dead code removal
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled

This commit is contained in:
2026-05-25 20:44:14 +03:00
parent a37a62c69e
commit a5abb6031b
3 changed files with 34 additions and 17 deletions
+8
View File
@@ -524,6 +524,12 @@ proc restoreHandler(server: HttpServer): RequestHandler =
let dbName = if body != nil and "database" in body: body["database"].getStr() else: ""
let dataRoot = server.registry.dataRoot
try:
# Verify archive integrity first
if not verifyArchive(inputFile, false):
logRestore(inputFile, dataRoot, false)
ctx.json(%*{"error": "Archive verification failed — file may be corrupted"}, 500)
return
let meta = readBackupMeta(inputFile)
let isMultiDb = meta != nil and meta{"databases"} != nil
var ok = false
@@ -534,6 +540,8 @@ proc restoreHandler(server: HttpServer): RequestHandler =
ok = restoreDataDir(inputFile, dbDir, false, false)
else:
ok = restoreAllDatabases(inputFile, dataRoot, false, false)
logRestore(inputFile, dataRoot, ok)
if ok:
# Reload databases after restore
server.registry.loadExistingDatabases()