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.
cute-signatures
Timo Teras 2009-01-22 21:45:18 +02:00
parent 3bcc676a2b
commit b8eb27d75b
1 changed files with 3 additions and 4 deletions

View File

@ -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);
} }