Added force parameter to tns_load() to disregard cache

This commit is contained in:
Bert 2011-08-19 13:26:58 +02:00
parent 421f012022
commit 1d7849efc1
4 changed files with 14 additions and 12 deletions

View File

@ -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)

2
main.c
View File

@ -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 {

View File

@ -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;

View File

@ -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);