diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-10-26 09:46:09 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-10-26 09:46:09 +0200 |
commit | a7360395ea963334e80fb49d3fc36789d6f40685 (patch) | |
tree | ac8d1de4c408d5feccb6d500895c1679f5ec7776 /src/database.c | |
parent | cc4644a54e4bb92507f957832647d91f7f91c21b (diff) | |
download | apk-tools-a7360395ea963334e80fb49d3fc36789d6f40685.tar.gz apk-tools-a7360395ea963334e80fb49d3fc36789d6f40685.tar.bz2 apk-tools-a7360395ea963334e80fb49d3fc36789d6f40685.tar.xz apk-tools-a7360395ea963334e80fb49d3fc36789d6f40685.zip |
db: fix migration and pruning of symlinks to dirs
the old code treated a symlink to directory as file; it tried
to calculate regular has of it. fix this by: 1) using no follow
on migration and pruning stats, and 2) the helper function to
check if it's point to directory and not calculate hash in that
case. fixes #188.
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c index 16f8bb8..5b1d6bb 100644 --- a/src/database.c +++ b/src/database.c @@ -1810,7 +1810,7 @@ static void apk_db_purge_pkg(struct apk_database *db, if (!(diri->dir->flags & APK_DBDIRF_PROTECTED) || (apk_flags & APK_PURGE) || (file->csum.type != APK_CHECKSUM_NONE && - apk_file_get_info(db->root_fd, name, file->csum.type, &fi) == 0 && + apk_file_get_info(db->root_fd, name, APK_FI_NOFOLLOW | file->csum.type, &fi) == 0 && apk_checksum_compare(&file->csum, &fi.csum) == 0)) unlinkat(db->root_fd, name, 0); if (apk_verbosity >= 3) @@ -1868,6 +1868,7 @@ static void apk_db_migrate_files(struct apk_database *db, if (ofile != NULL && (diri->dir->flags & APK_DBDIRF_PROTECTED)) cstype = ofile->csum.type; + cstype |= APK_FI_NOFOLLOW; r = apk_file_get_info(db->root_fd, name, cstype, &fi); if ((diri->dir->flags & APK_DBDIRF_PROTECTED) && @@ -1882,7 +1883,8 @@ static void apk_db_migrate_files(struct apk_database *db, * existing file */ if (ofile == NULL || ofile->csum.type != file->csum.type) - apk_file_get_info(db->root_fd, name, file->csum.type, &fi); + apk_file_get_info(db->root_fd, name, + APK_FI_NOFOLLOW | file->csum.type, &fi); if ((apk_flags & APK_CLEAN_PROTECTED) || (file->csum.type != APK_CHECKSUM_NONE && apk_checksum_compare(&file->csum, &fi.csum) == 0)) |