diff --git a/events.c b/events.c index a356b2f..2862d23 100644 --- a/events.c +++ b/events.c @@ -163,7 +163,7 @@ void run() { gettimeofday(&t0, 0); while (tns.cnt < filecnt && !XPending(win.env.dpy)) { - if (tns_load(&tns, tns.cnt, &files[tns.cnt], 0)) + if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False)) tns.cnt++; else remove_file(tns.cnt, 0); @@ -279,7 +279,7 @@ int it_toggle_fullscreen(arg_t a) { int it_reload_image(arg_t a) { if (mode == MODE_IMAGE) { load_image(fileidx); - } else if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) { + } else if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { remove_file(tns.sel, 0); tns.dirty = 1; if (tns.sel >= tns.cnt) @@ -578,11 +578,11 @@ int it_shell_cmd(arg_t a) { if (mode == MODE_IMAGE) { if (fileidx < tns.cnt) - tns_load(&tns, fileidx, &files[fileidx], 1); + tns_load(&tns, fileidx, &files[fileidx], False, True); img_close(&img, 1); load_image(fileidx); } else { - if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) { + if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { remove_file(tns.sel, 0); tns.dirty = 1; if (tns.sel >= tns.cnt) diff --git a/main.c b/main.c index d3c8e6f..d8dba0d 100644 --- a/main.c +++ b/main.c @@ -240,7 +240,7 @@ int main(int argc, char **argv) { if (options->thumbnails) { mode = MODE_THUMB; tns_init(&tns, filecnt); - while (!tns_load(&tns, 0, &files[0], 0)) + while (!tns_load(&tns, 0, &files[0], False, False)) remove_file(0, 0); tns.cnt = 1; } else { diff --git a/thumbs.c b/thumbs.c index 97bb2b2..425970d 100644 --- a/thumbs.c +++ b/thumbs.c @@ -212,9 +212,11 @@ void tns_free(tns_t *tns) { } } -int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { +int tns_load(tns_t *tns, int n, const fileinfo_t *file, + Bool force, Bool silent) +{ int w, h; - int use_cache, cached = 0; + int use_cache, cache_hit = 0; float z, zw, zh; thumb_t *t; Imlib_Image *im; @@ -234,11 +236,11 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { } if ((use_cache = tns_cache_enabled())) { - if ((im = tns_cache_load(file->path))) - cached = 1; + if (!force && (im = tns_cache_load(file->path))) + cache_hit = 1; } - if (!cached && + if (!cache_hit && (access(file->path, R_OK) || !(im = imlib_load_image(file->path)))) { if (!silent) @@ -262,7 +264,7 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { imlib_free_image_and_decache(); - if (use_cache && !cached) + if (use_cache && !cache_hit) tns_cache_write(t, False); tns->dirty = 1; diff --git a/thumbs.h b/thumbs.h index 27bd7fc..818ceb4 100644 --- a/thumbs.h +++ b/thumbs.h @@ -51,7 +51,7 @@ void tns_clean_cache(tns_t*); void tns_init(tns_t*, int); void tns_free(tns_t*); -int tns_load(tns_t*, int, const fileinfo_t*, unsigned char); +int tns_load(tns_t*, int, const fileinfo_t*, Bool, Bool); void tns_render(tns_t*, win_t*); void tns_highlight(tns_t*, win_t*, int, Bool);