summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-28 22:02:58 -0500
committerDan McGee <dan@archlinux.org>2011-06-30 11:51:49 -0500
commit13235ba65ab55d852dbdc0acabdc047442e74e28 (patch)
tree85adbf195f380908af76f9527e92bea451dcf0a9 /lib/libalpm/package.c
parentb94e8ecd1fec4426baab8c90e7fc0d5583acdbef (diff)
downloadpacman-13235ba65ab55d852dbdc0acabdc047442e74e28.tar.xz
Make local_db_read() private to the local backend
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. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 31f07325..21984b37 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -126,6 +126,8 @@ static int _pkg_changelog_close(const alpm_pkg_t UNUSED *pkg,
return EOF;
}
+static int _pkg_force_load(alpm_pkg_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 @@ alpm_pkg_t *_alpm_pkg_dup(alpm_pkg_t *pkg)
alpm_pkg_t *newpkg;
alpm_list_t *i;
+ if(pkg->ops->force_load(pkg)) {
+ return NULL;
+ }
+
CALLOC(newpkg, 1, sizeof(alpm_pkg_t), goto cleanup);
newpkg->name_hash = pkg->name_hash;