Skip to content

Commit

Permalink
create thumbnail directories if not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
giomatfois62 committed Feb 13, 2024
1 parent b57bc6d commit 29a2b39
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/rofi-icon-fetcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,26 +462,35 @@ static gchar* rofi_icon_fetcher_get_thumbnail(gchar* name,

// determine thumbnail folder based on the request size
const gchar* cache_dir = g_get_user_cache_dir();
gchar* thumb_dir;
gchar* thumb_path;

if (requested_size <= 128) {
*thumb_size = 128;
thumb_dir = g_strconcat(cache_dir, "/thumbnails/normal/", NULL);
thumb_path = g_strconcat(cache_dir, "/thumbnails/normal/",
md5_hex, ".png", NULL);
} else if (requested_size <= 256) {
*thumb_size = 256;
thumb_dir = g_strconcat(cache_dir, "/thumbnails/large/", NULL);
thumb_path = g_strconcat(cache_dir, "/thumbnails/large/",
md5_hex, ".png", NULL);
} else if (requested_size <= 512) {
*thumb_size = 512;
thumb_dir = g_strconcat(cache_dir, "/thumbnails/x-large/", NULL);
thumb_path = g_strconcat(cache_dir, "/thumbnails/x-large/",
md5_hex, ".png", NULL);
} else {
*thumb_size = 1024;
thumb_dir = g_strconcat(cache_dir, "/thumbnails/xx-large/", NULL);
thumb_path = g_strconcat(cache_dir, "/thumbnails/xx-large/",
md5_hex, ".png", NULL);
}


// create thumbnail directory if it does not exist
g_mkdir_with_parents(thumb_dir, 0700);

g_free(thumb_dir);
g_checksum_free(checksum);

return thumb_path;
Expand Down

0 comments on commit 29a2b39

Please sign in to comment.