nsxiv1d7849e
Added force parameter to tns_load() to disregard cache
+14 −12
4 files changed
| @@ -163,7 +163,7 @@ void run() { | |||
| 163 | 163 | gettimeofday(&t0, 0); | |
| 164 | 164 | ||
| 165 | 165 | while (tns.cnt < filecnt && !XPending(win.env.dpy)) { | |
| 166 | − | if (tns_load(&tns, tns.cnt, &files[tns.cnt], 0)) | |
| 166 | + | if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False)) | |
| 167 | 167 | tns.cnt++; | |
| 168 | 168 | else | |
| 169 | 169 | remove_file(tns.cnt, 0); | |
| @@ -279,7 +279,7 @@ int it_toggle_fullscreen(arg_t a) { | |||
| 279 | 279 | int it_reload_image(arg_t a) { | |
| 280 | 280 | if (mode == MODE_IMAGE) { | |
| 281 | 281 | load_image(fileidx); | |
| 282 | − | } else if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) { | |
| 282 | + | } else if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { | |
| 283 | 283 | remove_file(tns.sel, 0); | |
| 284 | 284 | tns.dirty = 1; | |
| 285 | 285 | if (tns.sel >= tns.cnt) | |
| @@ -578,11 +578,11 @@ int it_shell_cmd(arg_t a) { | |||
| 578 | 578 | ||
| 579 | 579 | if (mode == MODE_IMAGE) { | |
| 580 | 580 | if (fileidx < tns.cnt) | |
| 581 | − | tns_load(&tns, fileidx, &files[fileidx], 1); | |
| 581 | + | tns_load(&tns, fileidx, &files[fileidx], False, True); | |
| 582 | 582 | img_close(&img, 1); | |
| 583 | 583 | load_image(fileidx); | |
| 584 | 584 | } else { | |
| 585 | − | if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) { | |
| 585 | + | if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { | |
| 586 | 586 | remove_file(tns.sel, 0); | |
| 587 | 587 | tns.dirty = 1; | |
| 588 | 588 | if (tns.sel >= tns.cnt) | |
| @@ -240,7 +240,7 @@ int main(int argc, char **argv) { | |||
| 240 | 240 | if (options->thumbnails) { | |
| 241 | 241 | mode = MODE_THUMB; | |
| 242 | 242 | tns_init(&tns, filecnt); | |
| 243 | − | while (!tns_load(&tns, 0, &files[0], 0)) | |
| 243 | + | while (!tns_load(&tns, 0, &files[0], False, False)) | |
| 244 | 244 | remove_file(0, 0); | |
| 245 | 245 | tns.cnt = 1; | |
| 246 | 246 | } else { | |
| @@ -212,9 +212,11 @@ void tns_free(tns_t *tns) { | |||
| 212 | 212 | } | |
| 213 | 213 | } | |
| 214 | 214 | ||
| 215 | − | int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { | |
| 215 | + | int tns_load(tns_t *tns, int n, const fileinfo_t *file, | |
| 216 | + | Bool force, Bool silent) | |
| 217 | + | { | |
| 216 | 218 | int w, h; | |
| 217 | − | int use_cache, cached = 0; | |
| 219 | + | int use_cache, cache_hit = 0; | |
| 218 | 220 | float z, zw, zh; | |
| 219 | 221 | thumb_t *t; | |
| 220 | 222 | Imlib_Image *im; | |
| @@ -234,11 +236,11 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { | |||
| 234 | 236 | } | |
| 235 | 237 | ||
| 236 | 238 | if ((use_cache = tns_cache_enabled())) { | |
| 237 | − | if ((im = tns_cache_load(file->path))) | |
| 238 | − | cached = 1; | |
| 239 | + | if (!force && (im = tns_cache_load(file->path))) | |
| 240 | + | cache_hit = 1; | |
| 239 | 241 | } | |
| 240 | 242 | ||
| 241 | − | if (!cached && | |
| 243 | + | if (!cache_hit && | |
| 242 | 244 | (access(file->path, R_OK) || !(im = imlib_load_image(file->path)))) | |
| 243 | 245 | { | |
| 244 | 246 | if (!silent) | |
| @@ -262,7 +264,7 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) { | |||
| 262 | 264 | ||
| 263 | 265 | imlib_free_image_and_decache(); | |
| 264 | 266 | ||
| 265 | − | if (use_cache && !cached) | |
| 267 | + | if (use_cache && !cache_hit) | |
| 266 | 268 | tns_cache_write(t, False); | |
| 267 | 269 | ||
| 268 | 270 | tns->dirty = 1; | |
| @@ -51,7 +51,7 @@ void tns_clean_cache(tns_t*); | |||
| 51 | 51 | void tns_init(tns_t*, int); | |
| 52 | 52 | void tns_free(tns_t*); | |
| 53 | 53 | ||
| 54 | − | int tns_load(tns_t*, int, const fileinfo_t*, unsigned char); | |
| 54 | + | int tns_load(tns_t*, int, const fileinfo_t*, Bool, Bool); | |
| 55 | 55 | ||
| 56 | 56 | void tns_render(tns_t*, win_t*); | |
| 57 | 57 | void tns_highlight(tns_t*, win_t*, int, Bool); | |