@@ -120,8 +120,7 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force)
void tns_clean_cache(tns_t *tns)
void tns_clean_cache(tns_t *tns)
{
{
int dirlen;
int dirlen;
bool delete;
char *cfile, *filename, *tpos;
char *cfile, *filename;
r_dir_t dir;
r_dir_t dir;
if (r_opendir(&dir, cache_dir, true) < 0) {
if (r_opendir(&dir, cache_dir, true) < 0) {
@@ -133,15 +132,7 @@ void tns_clean_cache(tns_t *tns)
while ((cfile = r_readdir(&dir, false)) != NULL) {
while ((cfile = r_readdir(&dir, false)) != NULL) {
filename = cfile + dirlen;
filename = cfile + dirlen;
delete = false;
if ((tpos = strrchr(filename, '.')) != NULL) {
*tpos = '\0';
if (access(filename, F_OK) < 0)
delete = true;
*tpos = '.';
}
if (delete) {
if (access(filename, F_OK) < 0) {
if (unlink(cfile) < 0)
if (unlink(cfile) < 0)
error(0, errno, "%s", cfile);
error(0, errno, "%s", cfile);
}
}