fix(pacman): report database locks and refresh failures
A concurrent manager holding /var/lib/pacman/db.lck, or a partially failed `pacman -Sy`, surfaced as a generic failure with no explanation. Keep the last error, tell the user which lock is involved and how to recover, and stop treating a sync error as success. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
f1702932cd
commit
edc3ef2925
3 files changed
+134
-3
No files matched your search
@@ -113,6 +113,29 @@ static void testAuthFailed_ignoresPacmanErrors() {
|
||||
assert(!PacmanManager::authFailed("warning: firefox is up to date"));
|
||||
}
|
||||
|
||||
static void testDbLocked_detectsEnglishLock() {
|
||||
assert(PacmanManager::dbLocked(
|
||||
"error: failed to synchronize all databases (unable to lock database)"));
|
||||
}
|
||||
|
||||
static void testDbLocked_detectsFrenchLock() {
|
||||
assert(PacmanManager::dbLocked(
|
||||
"erreur : la synchronisation de toutes les bases de données a échoué "
|
||||
"(verrouillage de la base de données impossible)"));
|
||||
}
|
||||
|
||||
static void testDbLocked_detectsLockFile() {
|
||||
assert(PacmanManager::dbLocked(
|
||||
"error: failed to init transaction (unable to lock database)\n"
|
||||
" if you're sure a package manager is not already running, you can "
|
||||
"remove /var/lib/pacman/db.lck"));
|
||||
}
|
||||
|
||||
static void testDbLocked_ignoresUnrelatedErrors() {
|
||||
assert(!PacmanManager::dbLocked("error: target not found: firefox"));
|
||||
assert(!PacmanManager::dbLocked("Mise à jour terminée"));
|
||||
}
|
||||
|
||||
int main() {
|
||||
testParseInstalledOutput_parsesSimpleLines();
|
||||
testParseInstalledOutput_keepsHyphensInNames();
|
||||
@@ -132,6 +155,11 @@ int main() {
|
||||
testAuthFailed_detectsMissingPassword();
|
||||
testAuthFailed_ignoresPacmanErrors();
|
||||
|
||||
testDbLocked_detectsEnglishLock();
|
||||
testDbLocked_detectsFrenchLock();
|
||||
testDbLocked_detectsLockFile();
|
||||
testDbLocked_ignoresUnrelatedErrors();
|
||||
|
||||
std::cout << "All pacman-manager tests passed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user