Commit b8eb27d7 authored by Timo Teräs's avatar Timo Teräs

db: fix purging of packages from database

apk_hash_delete() actually deletes the file entry, so unlinking
from other lists need to happen before that. Also free the diri
instead of leaking it.
parent 3bcc676a
...@@ -1120,18 +1120,17 @@ static void apk_db_purge_pkg(struct apk_database *db, ...@@ -1120,18 +1120,17 @@ static void apk_db_purge_pkg(struct apk_database *db,
.dirname = APK_BLOB_STR(diri->dir->dirname), .dirname = APK_BLOB_STR(diri->dir->dirname),
.filename = APK_BLOB_STR(file->filename), .filename = APK_BLOB_STR(file->filename),
}; };
apk_hash_delete(&db->installed.files,
APK_BLOB_BUF(&key));
unlink(name); unlink(name);
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s\n", name); printf("%s\n", name);
__hlist_del(fc, &diri->owned_files.first); __hlist_del(fc, &diri->owned_files.first);
file->diri = NULL; apk_hash_delete(&db->installed.files,
APK_BLOB_BUF(&key));
db->installed.stats.files--; db->installed.stats.files--;
} }
apk_db_diri_rmdir(diri); apk_db_diri_rmdir(diri);
apk_db_dir_unref(db, diri->dir);
__hlist_del(dc, &pkg->owned_dirs.first); __hlist_del(dc, &pkg->owned_dirs.first);
apk_db_diri_free(db, diri);
} }
apk_pkg_set_state(db, pkg, APK_STATE_NO_INSTALL); apk_pkg_set_state(db, pkg, APK_STATE_NO_INSTALL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment