summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-12-21 18:12:45 +0200
committerTimo Teras <timo.teras@iki.fi>2009-12-21 18:12:45 +0200
commit884fabbf30837157b7f79f8b603f12dcc0730644 (patch)
tree606e0e55d56fa9a9d850f702649dea735b298d2b
parent6417de4d1057675bacc06274cab385810b86eed7 (diff)
downloadapk-tools-884fabbf30837157b7f79f8b603f12dcc0730644.tar.bz2
apk-tools-884fabbf30837157b7f79f8b603f12dcc0730644.tar.xz
db: honor overlay file even for protected paths
-rw-r--r--src/database.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/database.c b/src/database.c
index debe897..3ea8976 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1923,11 +1923,15 @@ static void apk_db_migrate_files(struct apk_database *db,
cstype |= APK_FI_NOFOLLOW;
r = apk_file_get_info(db->root_fd, name, cstype, &fi);
- if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
- (r == 0) &&
- (ofile == NULL ||
- ofile->csum.type == APK_CHECKSUM_NONE ||
- apk_checksum_compare(&ofile->csum, &fi.csum) != 0)) {
+ if (ofile->name == NULL) {
+ /* File was from overlay, delete the
+ * packages version */
+ unlinkat(db->root_fd, tmpname, 0);
+ } else if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
+ (r == 0) &&
+ (ofile == NULL ||
+ ofile->csum.type == APK_CHECKSUM_NONE ||
+ apk_checksum_compare(&ofile->csum, &fi.csum) != 0)) {
/* Protected directory, with file without
* db entry, or local modifications.
*
@@ -1942,15 +1946,9 @@ static void apk_db_migrate_files(struct apk_database *db,
apk_checksum_compare(&file->csum, &fi.csum) == 0))
unlinkat(db->root_fd, tmpname, 0);
} else {
- if (ofile->name == NULL) {
- /* File was from overlay, delete the
- * packages version */
- unlinkat(db->root_fd, tmpname, 0);
- } else {
- /* Overwrite the old file */
- renameat(db->root_fd, tmpname,
- db->root_fd, name);
- }
+ /* Overwrite the old file */
+ renameat(db->root_fd, tmpname,
+ db->root_fd, name);
}
/* Claim ownership of the file in db */