Mercurial > geeqie.yaz
changeset 65:322bb41c9b9e
Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
* cache.c: Make cache loader tolerant of unknown line values, so that
a cache written by newer/older versions of GQview does not result in
recreating data that is actually there.
author | gqview |
---|---|
date | Mon, 15 Aug 2005 22:32:57 +0000 |
parents | 04ff0df3ad2f |
children | ebbff299ad0d |
files | ChangeLog src/cache.c |
diffstat | 2 files changed, 37 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Aug 15 21:41:20 2005 +0000 +++ b/ChangeLog Mon Aug 15 22:32:57 2005 +0000 @@ -1,3 +1,9 @@ +Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net> + + * cache.c: Make cache loader tolerant of unknown line values, so that + a cache written by newer/older versions of GQview does not result in + recreating data that is actually there. + Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net> * collect-table.c, dupe.c, exif.c, img-view.c info.c, layout_image.c,
--- a/src/cache.c Mon Aug 15 21:41:20 2005 +0000 +++ b/src/cache.c Mon Aug 15 22:32:57 2005 +0000 @@ -182,16 +182,14 @@ *------------------------------------------------------------------- */ -static gint cache_sim_read_comment(FILE *f, char *buf, int s, CacheData *cd) +static gint cache_sim_read_skipline(FILE *f, int s) { - if (!f || !buf || !cd) return FALSE; + if (!f) return FALSE; - if (buf[0] != '#') return FALSE; - - if (fseek(f, 0 - (s - 1), SEEK_CUR) == 0) + if (fseek(f, 0 - s, SEEK_CUR) == 0) { char b; - while(fread(&b, sizeof(b), 1, f) == 1) + while (fread(&b, sizeof(b), 1, f) == 1) { if (b == '\n') return TRUE; } @@ -201,6 +199,15 @@ return FALSE; } +static gint cache_sim_read_comment(FILE *f, char *buf, int s, CacheData *cd) +{ + if (!f || !buf || !cd) return FALSE; + + if (s < 1 || buf[0] != '#') return FALSE; + + return cache_sim_read_skipline(f, s - 1); +} + static gint cache_sim_read_dimensions(FILE *f, char *buf, int s, CacheData *cd) { if (!f || !buf || !cd) return FALSE; @@ -425,12 +432,14 @@ return FALSE; } +#define CACHE_LOAD_LINE_NOISE 8 + CacheData *cache_sim_data_load(const gchar *path) { FILE *f; CacheData *cd = NULL; char buf[32]; - gint success = TRUE; + gint success = CACHE_LOAD_LINE_NOISE; gchar *pathl; if (!path) return NULL; @@ -448,17 +457,17 @@ strncmp(buf, "SIMcache", 8) != 0) { if (debug) printf("%s is not a cache file\n", cd->path); - success = FALSE; + success = 0; } - while (success) + while (success > 0) { int s; s = fread(&buf, sizeof(char), sizeof(buf), f); if (s < 1) { - success = FALSE; + success = 0; } else { @@ -469,7 +478,18 @@ !cache_sim_read_md5sum(f, buf, s, cd) && !cache_sim_read_similarity(f, buf, s, cd)) { - success = FALSE; + if (!cache_sim_read_skipline(f, s)) + { + success = 0; + } + else + { + success--; + } + } + else + { + success = CACHE_LOAD_LINE_NOISE; } } }