+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,
*-------------------------------------------------------------------
*/
-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 (buf[0] != '#') return FALSE;
+ if (!f) 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;
}
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;
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;
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
{
!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;
}
}
}