pkgdb: if plist from storage and memory do not differ do not flush to storage.

This commit is contained in:
Juan RP 2012-10-26 10:25:14 +02:00
parent 3e7f35bed1
commit e545429fa1

View File

@ -79,6 +79,7 @@ xbps_pkgdb_init(struct xbps_handle *xhp)
int int
xbps_pkgdb_update(struct xbps_handle *xhp, bool flush) xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
{ {
prop_array_t pkgdb_storage;
char *plist; char *plist;
static int cached_rv; static int cached_rv;
int rv = 0; int rv = 0;
@ -90,11 +91,16 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
assert(plist); assert(plist);
if (xhp->pkgdb && flush) { if (xhp->pkgdb && flush) {
pkgdb_storage = prop_array_internalize_from_zfile(plist);
assert(pkgdb_storage);
if (!prop_array_equals(xhp->pkgdb, pkgdb_storage)) {
/* flush dictionary to storage */ /* flush dictionary to storage */
if (!prop_array_externalize_to_file(xhp->pkgdb, plist)) { if (!prop_array_externalize_to_file(xhp->pkgdb, plist)) {
free(plist); free(plist);
return errno; return errno;
} }
}
prop_object_release(pkgdb_storage);
prop_object_release(xhp->pkgdb); prop_object_release(xhp->pkgdb);
xhp->pkgdb = NULL; xhp->pkgdb = NULL;
cached_rv = 0; cached_rv = 0;