Skip to content

Instantly share code, notes, and snippets.

@kekh
Created May 23, 2016 20:57
Show Gist options
  • Save kekh/b57a6b9a485c3c6e0334231157dcb5b1 to your computer and use it in GitHub Desktop.
Save kekh/b57a6b9a485c3c6e0334231157dcb5b1 to your computer and use it in GitHub Desktop.
An additional patch for file-roller GTK2 to put temporary files in /tmp instead of ~/.cache (and thus to reduce the amount of writes to SSDs). Backported from https://aur.archlinux.org/packages/file-roller-tmp/.
--- a/src/file-utils.c
+++ b/src/file-utils.c
@@ -886,26 +886,6 @@
}
-static const char *try_folder[] = { "cache", "~", "tmp", NULL };
-
-
-static char *
-ith_temp_folder_to_try (int n)
-{
- const char *folder;
-
- folder = try_folder[n];
- if (strcmp (folder, "cache") == 0)
- folder = g_get_user_cache_dir ();
- else if (strcmp (folder, "~") == 0)
- folder = g_get_home_dir ();
- else if (strcmp (folder, "tmp") == 0)
- folder = g_get_tmp_dir ();
-
- return g_strdup (folder);
-}
-
-
char *
get_temp_work_dir (const char *parent_folder)
{
@@ -916,22 +896,7 @@
char *result = NULL;
if (parent_folder == NULL) {
- /* find the folder with more free space. */
-
- for (i = 0; try_folder[i] != NULL; i++) {
- char *folder;
- guint64 size;
-
- folder = ith_temp_folder_to_try (i);
- size = get_dest_free_space (folder);
- if (max_size < size) {
- max_size = size;
- g_free (best_folder);
- best_folder = folder;
- }
- else
- g_free (folder);
- }
+ best_folder = g_strdup (g_get_tmp_dir ());
}
else
best_folder = g_strdup (parent_folder);
@@ -962,14 +927,12 @@
else if (dir[0] != '/')
return FALSE;
- for (i = 0; try_folder[i] != NULL; i++) {
-
- folder = ith_temp_folder_to_try (i);
- if (strncmp (dir, folder, strlen (folder)) == 0)
- if (strncmp (dir + strlen (folder), "/.fr-", 5) == 0) {
- g_free (folder);
- return TRUE;
- }
+ folder = g_strdup (g_get_tmp_dir ());
+ if (strncmp (dir, folder, strlen (folder)) == 0) {
+ if (strncmp (dir + strlen (folder), "/.fr-", 5) == 0) {
+ g_free (folder);
+ return TRUE;
+ }
}
g_free (folder);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment