From 6861b9cd1b2ba9c969a9d5b0954540c726a0755c Mon Sep 17 00:00:00 2001 From: gardners Date: Sun, 27 May 2012 18:13:49 +0200 Subject: [PATCH] bug fix for rhizome manifest cache (hopefully realises when database has been updated now). --- rhizome_fetch.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 0312da5f..f504ca1a 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -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 (revversion) { /* 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 */