Files
aptly/system/t08_db/recover.py
Silke Hofstra d8a4a28259 Remove corrupt package references in db recover
When aptly crashes it is possible to get a corrupt database with a dangling key reference.
This results in an error with 'key not found', eg:

    ERROR: unable to load package Pall example-package 1.2.3 778cf6f877bf6e2d: key not found

This change makes `db recover` fix this situation by removing the dangling references.
2025-04-30 12:21:34 +02:00

52 lines
1.1 KiB
Python

import os
from lib import BaseTest
class RecoverDB1Test(BaseTest):
"""
recover db: no DB
"""
runCmd = "aptly db recover"
class RecoverDB2Test(BaseTest):
"""
recover db: without CURRENT files
"""
fixtureDB = True
runCmd = "aptly db recover"
def prepare(self):
super(RecoverDB2Test, self).prepare()
self.delete_file("db/CURRENT")
def check(self):
self.check_output()
self.check_cmd_output("aptly mirror list", "mirror_list")
class RecoverDB3Test(BaseTest):
"""
recover db: dangling reference
"""
fixtureDB = True
fixtureCmds = [
"aptly repo create db3test",
"aptly repo add db3test changes/hardlink_0.2.1_amd64.deb",
]
runCmd = "aptly db recover"
def prepare(self):
super(RecoverDB3Test, self).prepare()
self.run_cmd(["go", "run", "files/corruptdb.go",
"-db", os.path.join(os.environ["HOME"], self.aptlyDir, "db"),
"-prefix", "Pamd64 hardlink 0.2.1"])
def check(self):
self.check_output()
self.check_cmd_output("aptly db cleanup", "cleanup")