From f482701eeec76109669a115e953445424bcfbad2 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Wed, 29 Jul 2009 19:39:59 +0300 Subject: db: fix protected directory handling (fixes #89) we don't want to do checksumming of existing files unless it's in a protected directory. also, we keep the original file if it's *modified*. --- src/database.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/database.c b/src/database.c index efa91b4..f308e48 100644 --- a/src/database.c +++ b/src/database.c @@ -1518,7 +1518,7 @@ static void apk_db_migrate_files(struct apk_database *db, struct hlist_node *dc, *dn, *fc, *fn; unsigned long hash; char name[1024], tmpname[1024]; - int r; + int cstype, r; hlist_for_each_entry_safe(diri, dc, dn, &pkg->owned_dirs, pkg_dirs_list) { dir = diri->dir; @@ -1540,13 +1540,18 @@ static void apk_db_migrate_files(struct apk_database *db, ofile = (struct apk_db_file *) apk_hash_get_hashed( &db->installed.files, APK_BLOB_BUF(&key), hash); - r = apk_file_get_info(name, - ofile ? ofile->csum.type : APK_CHECKSUM_NONE, - &fi); + /* We want to compare checksums only if one exists + * in db, and the file is in a protected path */ + cstype = APK_CHECKSUM_NONE; + if (ofile != NULL && + (diri->dir->flags & APK_DBDIRF_PROTECTED)) + cstype = ofile->csum.type; + + r = apk_file_get_info(name, cstype, &fi); if ((diri->dir->flags & APK_DBDIRF_PROTECTED) && (r == 0) && (ofile == NULL || - apk_checksum_compare(&ofile->csum, &fi.csum) == 0)) { + apk_checksum_compare(&ofile->csum, &fi.csum) != 0)) { /* Protected directory, with file without * db entry, or local modifications. * -- cgit v1.2.3