perform cleanup on sync db parsing errors

Cleanup was only being performed when libarchive failed to actually read
the file.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
Andrew Gregory 2024-02-07 00:30:54 -08:00 committed by Allan McRae
parent 5c75a55c7d
commit edd57c8b96

View file

@ -452,6 +452,14 @@ static int sync_db_populate(alpm_db_t *db)
} }
} }
} }
/* the db file was successfully read, but contained errors */
if(ret == -1) {
db->status &= ~DB_STATUS_VALID;
db->status |= DB_STATUS_INVALID;
_alpm_db_free_pkgcache(db);
GOTO_ERR(db->handle, ALPM_ERR_DB_INVALID, cleanup);
}
/* reading the db file failed */
if(archive_ret != ARCHIVE_EOF) { if(archive_ret != ARCHIVE_EOF) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not read db '%s' (%s)\n"), _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not read db '%s' (%s)\n"),
db->treename, archive_error_string(archive)); db->treename, archive_error_string(archive));