[Xfce4-commits] <midori:master> Verify that the download location is writable
Christian Dywan
noreply at xfce.org
Fri Oct 1 01:14:01 CEST 2010
Updating branch refs/heads/master
to bba6cb76ad995ed8e06b3ce9a88e0389b84a7593 (commit)
from 3bb34f9f9bad5028a376e5f1227e89abd6d1d49f (commit)
commit bba6cb76ad995ed8e06b3ce9a88e0389b84a7593
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Oct 1 01:12:12 2010 +0200
Verify that the download location is writable
midori/midori-browser.c | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index c988ae2..a719213 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -971,22 +971,42 @@ midori_browser_prepare_download (MidoriBrowser* browser,
G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, &error);
guint64 free_space = g_file_info_get_attribute_uint64 (info,
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+ gchar* path = g_file_get_path (folder);
+ gboolean can_write = g_access (path, W_OK) == 0;
+ g_free (path);
g_object_unref (file);
g_object_unref (folder);
- if (free_space < total_size)
- {
- gchar* message = g_strdup_printf (
- _("There is not enough free space to download \"%s\"."), &uri[7]);
- gchar* total_size_string = g_format_size_for_display (total_size);
- gchar* free_space_string = g_format_size_for_display (free_space);
- gchar* detailed_message = g_strdup_printf (
- _("The file needs %s but only %s are left."),
- total_size_string, free_space_string);
+ if (free_space < total_size || !can_write)
+ {
+ gchar* message;
+ gchar* detailed_message;
+
+ if (!can_write)
+ {
+ message = g_strdup_printf (
+ _("The file \"%s\" can't be saved in this folder."), &uri[7]);
+ detailed_message = g_strdup_printf (
+ _("You don't have permission to write in this location."));
+ }
+ else if (free_space < total_size)
+ {
+ gchar* total_size_string = g_format_size_for_display (total_size);
+ gchar* free_space_string = g_format_size_for_display (free_space);
+ message = g_strdup_printf (
+ _("There is not enough free space to download \"%s\"."),
+ &uri[7]);
+ detailed_message = g_strdup_printf (
+ _("The file needs %s but only %s are left."),
+ total_size_string, free_space_string);
+ g_free (total_size_string);
+ g_free (free_space_string);
+ }
+ else
+ g_assert_not_reached ();
+
sokoke_message_dialog (GTK_MESSAGE_ERROR, message, detailed_message);
g_free (message);
g_free (detailed_message);
- g_free (total_size_string);
- g_free (free_space_string);
g_object_unref (download);
return FALSE;
}
More information about the Xfce4-commits
mailing list