summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-06-26 16:28:22 +0300
committerTimo Teräs <timo.teras@iki.fi>2015-06-26 16:28:22 +0300
commit68453b99e68e8bc8454956cdcbbf6d0a520d666f (patch)
treee7455ef0bead42991d497b64824568e94135a967 /src
parent9dd161c2b4aa003368b4c0ac1d02ed5790415221 (diff)
downloadapk-tools-68453b99e68e8bc8454956cdcbbf6d0a520d666f.tar.gz
apk-tools-68453b99e68e8bc8454956cdcbbf6d0a520d666f.tar.bz2
apk-tools-68453b99e68e8bc8454956cdcbbf6d0a520d666f.tar.xz
apk-tools-68453b99e68e8bc8454956cdcbbf6d0a520d666f.zip
remove db dir entry properly, so it can be recreated properly if needed
fixes #4261
Diffstat (limited to 'src')
-rw-r--r--src/database.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/database.c b/src/database.c
index cafcfe8..7a9ab58 100644
--- a/src/database.c
+++ b/src/database.c
@@ -259,13 +259,13 @@ void apk_db_dir_unref(struct apk_database *db, struct apk_db_dir *dir, int rmdir
if (--dir->refs > 0) return;
db->installed.stats.dirs--;
apk_protected_path_array_free(&dir->protected_paths);
- if (dir->namelen == 0) return;
-
- if (rmdir_mode == APK_DIR_REMOVE && !(apk_flags & APK_SIMULATE))
- if (unlinkat(db->root_fd, dir->name, AT_REMOVEDIR))
- ;
-
- apk_db_dir_unref(db, dir->parent, rmdir_mode);
+ if (dir->namelen != 0) {
+ if (rmdir_mode == APK_DIR_REMOVE && !(apk_flags & APK_SIMULATE))
+ if (unlinkat(db->root_fd, dir->name, AT_REMOVEDIR))
+ ;
+ apk_db_dir_unref(db, dir->parent, rmdir_mode);
+ }
+ apk_hash_delete_hashed(&db->installed.dirs, APK_BLOB_PTR_LEN(dir->name, dir->namelen), dir->hash);
}
struct apk_db_dir *apk_db_dir_ref(struct apk_db_dir *dir)