db: fix protected directory handling
do not overwrite untracked files.cute-signatures
parent
680a301511
commit
0dadc27ce1
|
@ -1475,13 +1475,20 @@ static void apk_db_migrate_files(struct apk_database *db,
|
||||||
ofile = (struct apk_db_file *) apk_hash_get_hashed(
|
ofile = (struct apk_db_file *) apk_hash_get_hashed(
|
||||||
&db->installed.files, APK_BLOB_BUF(&key), hash);
|
&db->installed.files, APK_BLOB_BUF(&key), hash);
|
||||||
|
|
||||||
|
r = apk_file_get_info(name,
|
||||||
|
ofile ? ofile->csum.type : APK_CHECKSUM_NONE,
|
||||||
|
&fi);
|
||||||
if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
|
if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
|
||||||
ofile != NULL &&
|
(r == 0) &&
|
||||||
apk_file_get_info(name, ofile->csum.type, &fi) == 0 &&
|
(ofile == NULL ||
|
||||||
apk_checksum_compare(&ofile->csum, &fi.csum) != 0) {
|
apk_checksum_compare(&ofile->csum, &fi.csum) == 0)) {
|
||||||
/* Protected dir and existing file has been
|
/* Protected directory, with file without
|
||||||
* changed */
|
* db entry, or local modifications.
|
||||||
if (ofile->csum.type != file->csum.type)
|
*
|
||||||
|
* Delete the apk-new if it's identical with the
|
||||||
|
* existing file */
|
||||||
|
if (ofile == NULL ||
|
||||||
|
ofile->csum.type != file->csum.type)
|
||||||
apk_file_get_info(name, file->csum.type, &fi);
|
apk_file_get_info(name, file->csum.type, &fi);
|
||||||
if (apk_checksum_compare(&file->csum, &fi.csum) == 0)
|
if (apk_checksum_compare(&file->csum, &fi.csum) == 0)
|
||||||
unlink(tmpname);
|
unlink(tmpname);
|
||||||
|
@ -1504,32 +1511,6 @@ static void apk_db_migrate_files(struct apk_database *db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
|
|
||||||
apk_file_get_info(ae->name, file->csum.type, &fi) == 0 &&
|
|
||||||
apk_checksum_compare(&file->csum, &fi.csum) != 0) {
|
|
||||||
/* Protected file. Extract to separate place */
|
|
||||||
if (!(apk_flags & APK_CLEAN_PROTECTED)) {
|
|
||||||
snprintf(alt_name, sizeof(alt_name),
|
|
||||||
"%s/%s.apk-new",
|
|
||||||
diri->dir->name, file->name);
|
|
||||||
r = apk_archive_entry_extract(ae, is, alt_name,
|
|
||||||
extract_cb, ctx);
|
|
||||||
|
|
||||||
/* remove identical apk-new */
|
|
||||||
if (ae->csum.type != fi.csum.type)
|
|
||||||
apk_file_get_info(ae->name, ae->csum.type, &fi);
|
|
||||||
if (apk_checksum_compare(&ae->csum, &fi.csum) == 0)
|
|
||||||
unlink(alt_name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
r = apk_archive_entry_extract(ae, is, NULL,
|
|
||||||
extract_cb, ctx);
|
|
||||||
}
|
|
||||||
memcpy(&file->csum, &ae->csum, sizeof(file->csum));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static int apk_db_unpack_pkg(struct apk_database *db,
|
static int apk_db_unpack_pkg(struct apk_database *db,
|
||||||
struct apk_package *newpkg,
|
struct apk_package *newpkg,
|
||||||
int upgrade, apk_progress_cb cb, void *cb_ctx)
|
int upgrade, apk_progress_cb cb, void *cb_ctx)
|
||||||
|
|
Loading…
Reference in New Issue