bug fix for rhizome manifest cache (hopefully realises when

database has been updated now).
This commit is contained in:
gardners 2012-05-27 18:13:49 +02:00
parent 0f214ed46f
commit 6861b9cd1b

View File

@ -176,18 +176,27 @@ int rhizome_manifest_version_cache_lookup(rhizome_manifest *m)
if (i==24) {
/* Entries match -- so check version */
unsigned long long rev = rhizome_manifest_get_ll(m,"version");
if (0) WHYF("cached version same or newer (%lld)",entry->version);
if (1) WHYF("cached version %lld vs manifest version %lld",
entry->version,rev);
if (rev>entry->version) {
/* If we only have an old version, try refreshing the cache
by querying the database */
entry->version = sqlite_exec_int64("select version from manifests where id='%s'", id);
}
if (rev<entry->version) {
/* the presented manifest is older than we have.
This allows the caller to know that they can tell whoever gave them the
manifest it's time to get with the times. May or not ever be
implemented, but it would be nice. XXX */
WHY("cached version is NEWER than presented version");
return -2;
} else if (rev<=entry->version) {
/* the presented manifest is already stored. */
WHY("cached version is NEWER/SAME as presented version");
return -1;
} else {
/* the presented manifest is newer than we have */
WHY("cached version is older than presented version");
return 0;
}
} else {
@ -371,6 +380,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m,
if (1) DEBUGF("Rhizome considering %s (size=%lld, priority=%d)",
id,filesize,priority);
m->version=rhizome_manifest_get_ll(m,"version");
if (rhizome_manifest_version_cache_lookup(m)) {
/* We already have this version or newer */