diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-02-10 15:58:35 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-02-10 15:58:35 +0200 |
commit | f2e41a488e51a973015719625947183416056e26 (patch) | |
tree | b3e9ec574a0d27c60918cd203d82c930fae947fc /src | |
parent | 29ebf435d701ff33decd6a28775f7406ca938949 (diff) | |
download | apk-tools-f2e41a488e51a973015719625947183416056e26.tar.gz apk-tools-f2e41a488e51a973015719625947183416056e26.tar.bz2 apk-tools-f2e41a488e51a973015719625947183416056e26.tar.xz apk-tools-f2e41a488e51a973015719625947183416056e26.zip |
db: fix directory permissions recalculation
Diffstat (limited to 'src')
-rw-r--r-- | src/database.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c index cb7428f..1ced84f 100644 --- a/src/database.c +++ b/src/database.c @@ -239,24 +239,27 @@ static void apk_db_dir_unref(struct apk_database *db, struct apk_db_dir *dir, if (dir->refs > 0) { if (allow_rmdir) { dir->flags |= APK_DBDIRF_RECALC_MODE; + dir->mode = 0; + dir->uid = (uid_t) -1; + dir->gid = (gid_t) -1; } return; } - if ((allow_rmdir == APK_DISALLOW_RMDIR) && - (dir->flags & APK_DBDIRF_RECALC_MODE)) { - apk_db_dir_mkdir(db, dir); - } - db->installed.stats.dirs--; if (allow_rmdir) { + /* The final instance of this directory was removed, + * so this directory gets deleted in reality too. */ dir->flags &= ~APK_DBDIRF_RECALC_MODE; dir->mode = 0; dir->uid = (uid_t) -1; dir->gid = (gid_t) -1; unlinkat(db->root_fd, dir->name, AT_REMOVEDIR); + } else if (dir->flags & APK_DBDIRF_RECALC_MODE) { + /* Directory permissions need a reset. */ + apk_db_dir_mkdir(db, dir); } if (dir->parent != NULL) |