There is little need to expose the guts of this function even within the
library. Make it static in be_local.c, and clean up a few other things
since we know exactly where it is being called from:
* Remove unnecessary origin checks in _cache_get_*() methods- if you are
calling a cache method your package type will be correct.
* Remove sanity checks within local_db_read() itself- packages will
always have a name and version if they get this far, and the package
object will never be NULL either.
The one case calling this from outside the backend was in add.c, where
we forced a full load of a package before we duplicated it. Move this
concern elsewhere and have pkg_dup() always force a full package load
via a new force_load() function on the operations callback struct.
/* we'll need to save some record for backup checks later */
oldpkg = _alpm_pkg_dup(local);
- /* make sure all infos are loaded because the database entry
- * will be removed soon */
- _alpm_local_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
/* be_*.c, backend specific calls */
-int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info);
int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_local_db_remove(pmdb_t *db, pmpkg_t *info);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 75ac94c..f44cd41 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -126,6 +126,8 @@ static int _pkg_changelog_close(const pmpkg_t UNUSED *pkg,
return EOF;
}
+static int _pkg_force_load(pmpkg_t UNUSED *pkg) { return 0; }
+
/** The standard package operations struct. Get fields directly from the
* struct itself with no abstraction layer or any type of lazy loading.
*/
@@ -157,6 +159,8 @@ struct pkg_operations default_pkg_ops = {
.changelog_open = _pkg_changelog_open,
.changelog_read = _pkg_changelog_read,
.changelog_close = _pkg_changelog_close,
+
+ .force_load = _pkg_force_load,
};
/* Public functions for getting package information. These functions
@@ -437,6 +441,10 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
pmpkg_t *newpkg;
alpm_list_t *i;