aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-29 19:39:59 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-29 19:39:59 +0300
commitf482701eeec76109669a115e953445424bcfbad2 (patch)
tree54914d562b9cbbc094520e9a5f0bd5941d78156a
parent2ff4059b9a4073459cb75406df1a6f2d7717e72e (diff)
downloadapk-tools-f482701eeec76109669a115e953445424bcfbad2.tar.gz
apk-tools-f482701eeec76109669a115e953445424bcfbad2.tar.bz2
apk-tools-f482701eeec76109669a115e953445424bcfbad2.tar.xz
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*.
-rw-r--r--src/database.c15
1 files 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.
*