--- a/src/lib/cache.c Mon Dec 28 19:54:41 2009 +0200
+++ b/src/lib/cache.c Mon Dec 28 19:58:51 2009 +0200
@@ -10,7 +10,7 @@
-static int pt_cache_new (struct pt_cache **cache_ptr, const char *path)
+static int pt_cache_new (struct pt_cache **cache_ptr, const char *path, int mode)
{
struct pt_cache *cache;
@@ -23,6 +23,7 @@
// init
cache->fd = -1;
+ cache->mode = mode;
// ok
*cache_ptr = cache;
@@ -42,7 +43,7 @@
struct pt_cache *cache;
// alloc
- if (pt_cache_new(&cache, path))
+ if (pt_cache_new(&cache, path, mode))
return -1;
// ok
--- a/src/lib/image.c Mon Dec 28 19:54:41 2009 +0200
+++ b/src/lib/image.c Mon Dec 28 19:58:51 2009 +0200
@@ -175,14 +175,17 @@
if (pt_cache_open(&image->cache, cache_path, cache_mode))
goto error;
- // update if not fresh
+ // compare cache with image
// XXX: check cache_mode
if ((stale = pt_cache_stale(image->cache, image->path)) < 0)
goto error;
- if (stale)
- pt_image_update_cache(image);
-
+ // update if not fresh
+ if (stale) {
+ if (pt_image_update_cache(image))
+ goto error;
+ }
+
// ok, ready for access
*image_ptr = image;