fix home directory spam, that could've been bad
This commit is contained in:
parent
5ae0fc4eea
commit
f2db911334
25
libs/img.c
25
libs/img.c
|
@ -189,8 +189,9 @@ loadimagecache(const char *file, int *width, int *height)
|
|||
return;
|
||||
}
|
||||
|
||||
if (generatecache) {
|
||||
/* try find image from cache first */
|
||||
if(!(xdg_cache = getenv("XDG_CACHE_HOME")) && generatecache) {
|
||||
if(!(xdg_cache = getenv("XDG_CACHE_HOME"))) {
|
||||
if(!(home = getenv("HOME")) && (pw = getpwuid(getuid())))
|
||||
home = pw->pw_dir;
|
||||
if(!home) {
|
||||
|
@ -221,9 +222,9 @@ loadimagecache(const char *file, int *width, int *height)
|
|||
sprintf(&md5[i*2], "%02x", (unsigned int)digest[i]);
|
||||
|
||||
/* path for cached thumbnail */
|
||||
if (xdg_cache && generatecache)
|
||||
if (xdg_cache)
|
||||
slen = snprintf(NULL, 0, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5)+1;
|
||||
else if (generatecache)
|
||||
else
|
||||
slen = snprintf(NULL, 0, "%s/.thumbnails/%s/%s.png", home, dsize, md5)+1;
|
||||
|
||||
if(!(buf = malloc(slen))) {
|
||||
|
@ -231,12 +232,12 @@ loadimagecache(const char *file, int *width, int *height)
|
|||
return;
|
||||
}
|
||||
|
||||
if (xdg_cache && generatecache)
|
||||
if (xdg_cache)
|
||||
sprintf(buf, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5);
|
||||
else if (generatecache)
|
||||
else
|
||||
sprintf(buf, "%s/.thumbnails/%s/%s.png", home, dsize, md5);
|
||||
|
||||
if (generatecache) loadimage(buf, width, height);
|
||||
loadimage(buf, width, height);
|
||||
|
||||
if (image && *width < imagewidth && *height < imageheight) {
|
||||
imlib_free_image();
|
||||
|
@ -250,20 +251,22 @@ loadimagecache(const char *file, int *width, int *height)
|
|||
free(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* we din't find anything from cache, or it was just wrong */
|
||||
loadimage(file, width, height);
|
||||
if (!image) {
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
scaleimage(width, height);
|
||||
|
||||
if (!generatecache) return;
|
||||
|
||||
imlib_image_set_format("png");
|
||||
|
||||
if (buf && generatecache) {
|
||||
createifnexist_rec(buf);
|
||||
imlib_save_image(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
jumptoindex(unsigned int index) {
|
||||
|
|
Loading…
Reference in a new issue