summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-01-06 21:10:00 +0200
committerTimo Teras <timo.teras@iki.fi>2009-01-06 21:23:26 +0200
commitc7ffc96a16c6963fe0a07be7ee75e8f1f7426882 (patch)
treefc57d9464859cb5fff7851d0bfbba152aab07628 /src
parent0655699133873807acd1f097633af376d98832a6 (diff)
downloadapk-tools-c7ffc96a16c6963fe0a07be7ee75e8f1f7426882.tar.gz
apk-tools-c7ffc96a16c6963fe0a07be7ee75e8f1f7426882.tar.bz2
apk-tools-c7ffc96a16c6963fe0a07be7ee75e8f1f7426882.tar.xz
apk-tools-c7ffc96a16c6963fe0a07be7ee75e8f1f7426882.zip
db: rmdir() directories only on package purge
Diffstat (limited to 'src')
-rw-r--r--src/database.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/database.c b/src/database.c
index 3901ad2..42da186 100644
--- a/src/database.c
+++ b/src/database.c
@@ -113,7 +113,6 @@ static void apk_db_dir_put(struct apk_database *db, struct apk_db_dir *dir)
return;
db->installed.stats.dirs--;
- rmdir(dir->dirname);
if (dir->parent != NULL)
apk_db_dir_put(db, dir->parent);
@@ -190,7 +189,7 @@ static void apk_db_diri_set(struct apk_db_dir_instance *diri, mode_t mode,
diri->gid = gid;
}
-static void apk_db_diri_create(struct apk_db_dir_instance *diri)
+static void apk_db_diri_mkdir(struct apk_db_dir_instance *diri)
{
if (diri->dir->refs == 1) {
mkdir(diri->dir->dirname, diri->mode);
@@ -198,6 +197,13 @@ static void apk_db_diri_create(struct apk_db_dir_instance *diri)
}
}
+static void apk_db_diri_rmdir(struct apk_db_dir_instance *diri)
+{
+ if (diri->dir->refs == 1) {
+ rmdir(diri->dir->dirname);
+ }
+}
+
static void apk_db_diri_free(struct apk_database *db,
struct apk_db_dir_instance *diri)
{
@@ -889,7 +895,7 @@ static int apk_db_install_archive_entry(void *_ctx,
ctx->file_diri_node = NULL;
apk_db_diri_set(diri, ae->mode & 0777, ae->uid, ae->gid);
- apk_db_diri_create(diri);
+ apk_db_diri_mkdir(diri);
}
return r;
@@ -914,6 +920,7 @@ static void apk_db_purge_pkg(struct apk_database *db,
db->installed.stats.files--;
}
+ apk_db_diri_rmdir(diri);
apk_db_dir_put(db, diri->dir);
__hlist_del(dc, &pkg->owned_dirs.first);
}