Do not create cache files for cache files
This commit is contained in:
parent
92709b2b2f
commit
7d40faeba6
17
thumbs.c
17
thumbs.c
|
@ -327,7 +327,8 @@ int tns_cache_enabled() {
|
||||||
|
|
||||||
char* tns_cache_filename(const char *filename) {
|
char* tns_cache_filename(const char *filename) {
|
||||||
size_t len;
|
size_t len;
|
||||||
char *cfile, *abspath;
|
char *cfile = NULL;
|
||||||
|
const char *abspath;
|
||||||
|
|
||||||
if (!cache_dir || !filename)
|
if (!cache_dir || !filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -336,15 +337,17 @@ char* tns_cache_filename(const char *filename) {
|
||||||
if (!(abspath = absolute_path(filename)))
|
if (!(abspath = absolute_path(filename)))
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
abspath = (char*) s_malloc(strlen(filename) + 1);
|
abspath = filename;
|
||||||
strcpy(abspath, filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(cache_dir) + strlen(abspath) + 6;
|
if (strncmp(abspath, cache_dir, strlen(cache_dir))) {
|
||||||
cfile = (char*) s_malloc(len);
|
len = strlen(cache_dir) + strlen(abspath) + 6;
|
||||||
snprintf(cfile, len, "%s/%s.png", cache_dir, abspath + 1);
|
cfile = (char*) s_malloc(len);
|
||||||
|
snprintf(cfile, len, "%s/%s.png", cache_dir, abspath + 1);
|
||||||
|
}
|
||||||
|
|
||||||
free(abspath);
|
if (abspath != filename)
|
||||||
|
free((void*) abspath);
|
||||||
|
|
||||||
return cfile;
|
return cfile;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue