]> spindle.queued.net Git - midori/commitdiff
Check for destination folder before downloading userstyle/script
authorPaweł Forysiuk <tuxator@o2.pl>
Sat, 5 Feb 2011 22:01:46 +0000 (23:01 +0100)
committerChristian Dywan <christian@twotoasts.de>
Tue, 8 Feb 2011 23:22:51 +0000 (00:22 +0100)
extensions/addons.c

index eb23f43e879bd0b84f7cb21a4c119b3e794d9ff0..74ff22c902752be1ec3cdd8c7d88a808bed376c9 100644 (file)
@@ -108,7 +108,7 @@ addons_install_response (GtkWidget*  infobar,
         if (uri && *uri)
         {
             gchar** split_uri;
-            gchar* path, *filename, *hostname, *dest_path, *temp_uri;
+            gchar* path, *filename, *hostname, *dest_path, *temp_uri, *folder_path;
             const gchar* folder;
             WebKitNetworkRequest* request;
             WebKitDownload* download;
@@ -188,8 +188,12 @@ addons_install_response (GtkWidget*  infobar,
 
             if (!filename)
                 filename = g_path_get_basename (uri);
-            path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
-                                 PACKAGE_NAME, folder, filename, NULL);
+            folder_path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+                                 PACKAGE_NAME, folder, NULL);
+
+            if (!g_file_test (folder_path, G_FILE_TEST_EXISTS))
+                katze_mkdir_with_parents (folder_path, 0700);
+            path = g_build_path (G_DIR_SEPARATOR_S, folder_path, filename, NULL);
 
             request = webkit_network_request_new (uri);
             download = webkit_download_new (request);
@@ -203,6 +207,7 @@ addons_install_response (GtkWidget*  infobar,
             g_free (path);
             g_free (temp_uri);
             g_free (dest_path);
+            g_free (folder_path);
             g_strfreev (split_uri);
         }
     }