From: Klaus Ethgen Date: Sun, 15 May 2016 10:00:52 +0000 (+0100) Subject: Removing obsolete checksum stuff X-Git-Tag: v1.3~22 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=316293b29ac822c5887a8afd57e9a2b7c4a4f6ab Removing obsolete checksum stuff That checksum stuff for similarity check is replaced with MD5 from the very begin. Removing that ancient code. --- diff --git a/src/cache.c b/src/cache.c index a3320b0c..053d79fb 100644 --- a/src/cache.c +++ b/src/cache.c @@ -30,7 +30,6 @@ * #comment * Dimensions=[ x ] * Date=[] - * Checksum=[] * MD5sum=[<32 character ascii text digest>] * SimilarityGrid[32 x 32]=<3072 bytes of data (1024 pixels in RGB format, 1 pixel is 24bits)> * @@ -92,15 +91,6 @@ static gboolean cache_sim_write_date(SecureSaveInfo *ssi, CacheData *cd) return TRUE; } -static gboolean cache_sim_write_checksum(SecureSaveInfo *ssi, CacheData *cd) -{ - if (!cd || !cd->have_checksum) return FALSE; - - secure_fprintf(ssi, "Checksum=[%ld]\n", cd->checksum); - - return TRUE; -} - static gboolean cache_sim_write_md5sum(SecureSaveInfo *ssi, CacheData *cd) { gchar *text; @@ -165,7 +155,6 @@ gboolean cache_sim_data_save(CacheData *cd) secure_fprintf(ssi, "SIMcache\n#%s %s\n", PACKAGE, VERSION); cache_sim_write_dimensions(ssi, cd); cache_sim_write_date(ssi, cd); - cache_sim_write_checksum(ssi, cd); cache_sim_write_md5sum(ssi, cd); cache_sim_write_similarity(ssi, cd); @@ -294,46 +283,6 @@ static gboolean cache_sim_read_date(FILE *f, gchar *buf, gint s, CacheData *cd) return FALSE; } -static gboolean cache_sim_read_checksum(FILE *f, gchar *buf, gint s, CacheData *cd) -{ - if (!f || !buf || !cd) return FALSE; - - if (s < 8 || strncmp("Checksum", buf, 8) != 0) return FALSE; - - if (fseek(f, - s, SEEK_CUR) == 0) - { - gchar b; - gchar buf[1024]; - gsize p = 0; - - b = 'X'; - while (b != '[') - { - if (fread(&b, sizeof(b), 1, f) != 1) return FALSE; - } - while (b != ']' && p < sizeof(buf) - 1) - { - if (fread(&b, sizeof(b), 1, f) != 1) return FALSE; - buf[p] = b; - p++; - } - - while (b != '\n') - { - if (fread(&b, sizeof(b), 1, f) != 1) break; - } - - buf[p] = '\0'; - cd->checksum = strtol(buf, NULL, 10); - - cd->have_checksum = TRUE; - - return TRUE; - } - - return FALSE; -} - static gboolean cache_sim_read_md5sum(FILE *f, gchar *buf, gint s, CacheData *cd) { if (!f || !buf || !cd) return FALSE; @@ -477,7 +426,6 @@ CacheData *cache_sim_data_load(const gchar *path) if (!cache_sim_read_comment(f, buf, s, cd) && !cache_sim_read_dimensions(f, buf, s, cd) && !cache_sim_read_date(f, buf, s, cd) && - !cache_sim_read_checksum(f, buf, s, cd) && !cache_sim_read_md5sum(f, buf, s, cd) && !cache_sim_read_similarity(f, buf, s, cd)) { @@ -501,7 +449,6 @@ CacheData *cache_sim_data_load(const gchar *path) if (!cd->dimensions && !cd->have_date && - !cd->have_checksum && !cd->have_md5sum && !cd->similarity) { @@ -535,14 +482,6 @@ void cache_sim_data_set_date(CacheData *cd, time_t date) cd->have_date = TRUE; } -void cache_sim_data_set_checksum(CacheData *cd, glong checksum) -{ - if (!cd) return; - - cd->checksum = checksum; - cd->have_checksum = TRUE; -} - void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]) { gint i; diff --git a/src/cache.h b/src/cache.h index 2a9267a9..e62a4306 100644 --- a/src/cache.h +++ b/src/cache.h @@ -44,13 +44,11 @@ struct _CacheData gint width; gint height; time_t date; - glong checksum; guchar md5sum[16]; ImageSimilarityData *sim; gboolean dimensions; gboolean have_date; - gboolean have_checksum; gboolean have_md5sum; gboolean similarity; }; @@ -66,7 +64,6 @@ CacheData *cache_sim_data_load(const gchar *path); void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h); void cache_sim_data_set_date(CacheData *cd, time_t date); -void cache_sim_data_set_checksum(CacheData *cd, glong checksum); void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]); void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd); gint cache_sim_data_filled(ImageSimilarityData *sd); diff --git a/src/dupe.c b/src/dupe.c index 5e57a627..19391a39 100644 --- a/src/dupe.c +++ b/src/dupe.c @@ -404,10 +404,6 @@ static void dupe_item_read_cache(DupeItem *di) di->width = cd->width; di->height = cd->height; } - if (di->checksum == 0 && cd->have_checksum) - { - di->checksum = cd->checksum; - } if (!di->md5sum && cd->have_md5sum) { di->md5sum = md5_digest_to_text(cd->md5sum); @@ -432,7 +428,6 @@ static void dupe_item_write_cache(DupeItem *di) cd->path = cache_get_location(CACHE_TYPE_SIM, di->fd->path, TRUE, NULL); if (di->width != 0) cache_sim_data_set_dimensions(cd, di->width, di->height); - if (di->checksum != 0) cache_sim_data_set_checksum(cd, di->checksum); if (di->md5sum) { guchar digest[16]; diff --git a/src/dupe.h b/src/dupe.h index f760c215..f75efaac 100644 --- a/src/dupe.h +++ b/src/dupe.h @@ -24,7 +24,7 @@ typedef enum DUPE_MATCH_SIZE = 1 << 1, DUPE_MATCH_DATE = 1 << 2, DUPE_MATCH_DIM = 1 << 3, /* image dimensions */ - DUPE_MATCH_SUM = 1 << 4, /* simple checksum */ + DUPE_MATCH_SUM = 1 << 4, /* MD5sum */ DUPE_MATCH_PATH = 1 << 5, DUPE_MATCH_SIM_HIGH = 1 << 6, /* similarity */ DUPE_MATCH_SIM_MED = 1 << 7, @@ -41,7 +41,6 @@ struct _DupeItem FileData *fd; - glong checksum; gchar *md5sum; gint width; gint height;