Merge lp:~dobey/ubuntuone-client/sharing-error into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: Tim Cole
Approved revision: 217
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/sharing-error
Merge into: lp:ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/sharing-error
Reviewer Review Type Date Requested Status
Tim Cole (community) Approve
John O'Brien (community) Approve
Review via email: mp+12088@code.launchpad.net

Commit message

Handle ShareCreateError in the nautilus extension, and show an error dialog
Fix the _create_share_http code to call the errback/callback properly
Add the path to the share_info dict on errors
Fix volume_manager and tests to get mdid properly

To post a comment you must log in.
Revision history for this message
John O'Brien (jdobrien) :
review: Approve
Revision history for this message
Tim Cole (tcole) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus/ubuntuone-nautilus.c'
2--- nautilus/ubuntuone-nautilus.c 2009-09-14 15:48:56 +0000
3+++ nautilus/ubuntuone-nautilus.c 2009-09-18 18:41:10 +0000
4@@ -115,6 +115,10 @@
5 static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,
6 GHashTable * hash,
7 gpointer user_data);
8+static void ubuntuone_nautilus_sharing_error (DBusGProxy * proxy,
9+ GHashTable * hash,
10+ gchar * error,
11+ gpointer user_data);
12
13 static GObjectClass * parent_class = NULL;
14
15@@ -622,6 +626,15 @@
16 dbus_g_proxy_connect_signal (uon->u1_shares, "ShareCreated",
17 G_CALLBACK (ubuntuone_nautilus_share_created),
18 uon, NULL);
19+ dbus_g_proxy_add_signal (uon->u1_shares, "ShareCreateError",
20+ dbus_g_type_get_map ("GHashTable",
21+ G_TYPE_STRING,
22+ G_TYPE_STRING),
23+ G_TYPE_STRING,
24+ G_TYPE_INVALID);
25+ dbus_g_proxy_connect_signal (uon->u1_shares, "ShareCreateError",
26+ G_CALLBACK (ubuntuone_nautilus_sharing_error),
27+ uon, NULL);
28 }
29
30 static void ubuntuone_nautilus_class_init (UbuntuOneNautilusClass * klass) {
31@@ -887,7 +900,8 @@
32 }
33
34 static void ubuntuone_nautilus_download_finished (DBusGProxy * proxy,
35- gchar * path, GHashTable * info,
36+ gchar * path,
37+ GHashTable * info,
38 gpointer user_data) {
39 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
40 gchar * partial = NULL;
41@@ -919,6 +933,33 @@
42 }
43 }
44
45+static void ubuntuone_nautilus_sharing_error (DBusGProxy * proxy,
46+ GHashTable * hash,
47+ gchar * error,
48+ gpointer user_data) {
49+ UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
50+ gchar * path, * message;
51+ GtkWidget * dialog;
52+
53+ path = g_hash_table_lookup (hash, "path");
54+
55+ dialog = gtk_message_dialog_new (GTK_WINDOW (uon->share_cb_data->parent),
56+ GTK_DIALOG_DESTROY_WITH_PARENT |
57+ GTK_DIALOG_NO_SEPARATOR,
58+ GTK_MESSAGE_ERROR,
59+ GTK_BUTTONS_CLOSE,
60+ _("Error creating share."));
61+ message = g_strdup_printf (_("There was an error sharing the folder '%s':\n%s"),
62+ path,
63+ error);
64+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
65+ "%s", message);
66+ g_free (message);
67+ g_signal_connect_swapped (G_OBJECT (dialog), "response",
68+ G_CALLBACK (gtk_widget_destroy), dialog);
69+ gtk_widget_show (dialog);
70+}
71+
72 /* Required Nautilus module handling methods */
73 void nautilus_module_initialize (GTypeModule * module) {
74 #ifdef ENABLE_NLS
75
76=== modified file 'tests/syncdaemon/test_dbus.py'
77--- tests/syncdaemon/test_dbus.py 2009-08-26 06:04:50 +0000
78+++ tests/syncdaemon/test_dbus.py 2009-09-18 18:41:10 +0000
79@@ -1118,7 +1118,8 @@
80 a_dir = os.path.join(self.root_dir, "a_dir")
81 self.fs_manager.create(a_dir, "", is_dir=True)
82 self.fs_manager.set_node_id(a_dir, "node_id")
83- mdid = self.fs_manager.get_by_node_id("", "node_id")
84+ mdobj = self.fs_manager.get_by_node_id("", "node_id")
85+ mdid = mdobj.mdid
86 marker = MDMarker(mdid)
87 d = defer.Deferred()
88 def share_handler(result):
89@@ -1137,7 +1138,8 @@
90 a_dir = os.path.join(self.root_dir, "a_dir")
91 self.fs_manager.create(a_dir, "", is_dir=True)
92 self.fs_manager.set_node_id(a_dir, "node_id")
93- mdid = self.fs_manager.get_by_node_id("", "node_id")
94+ mdobj = self.fs_manager.get_by_node_id("", "node_id")
95+ mdid = mdobj.mdid
96 marker = MDMarker(mdid)
97 error_msg = 'a error message'
98 d = defer.Deferred()
99
100=== modified file 'ubuntuone/syncdaemon/action_queue.py'
101--- ubuntuone/syncdaemon/action_queue.py 2009-09-10 18:49:01 +0000
102+++ ubuntuone/syncdaemon/action_queue.py 2009-09-18 18:41:10 +0000
103@@ -1799,7 +1799,7 @@
104 """
105 return self.demark(self.node_id)
106
107- def _create_share_http(self, node_id, user, name, modify):
108+ def _create_share_http(self, node_id, user, name, modify, deferred):
109 """Create a share using the HTTP Web API method."""
110
111 consumer = oauth.OAuthConsumer("ubuntuone", "hammertime")
112@@ -1821,24 +1821,23 @@
113 try:
114 urlopen(req)
115 except HTTPError, e:
116- self.log.error('Failed to create share for %s: %s',
117- str(node_id), e.strerror)
118+ deferred.errback(Failure(e))
119+
120+ deferred.callback()
121
122 def _run(self):
123 """
124 Do the actual running
125 """
126 if self.use_http:
127- # External user, do the Web API method
128- def failed_thread(error):
129- """Failed to launch the share creation thread."""
130- self.log.error("Failed to create share: %s",
131- error.getErrorMessage())
132+ # External user, do the HTTP REST method
133+ deferred = defer.Deferred()
134 d = threads.deferToThread(self._create_share_http,
135 self.node_id, self.share_to,
136- self.name, self.access_level)
137- d.addErrback(failed_thread)
138- return d
139+ self.name, self.access_level,
140+ deferred)
141+ d.addErrback(deferred.errback)
142+ return deferred
143 else:
144 return self.action_queue.client.create_share(self.node_id,
145 self.share_to,
146@@ -1849,6 +1848,7 @@
147 """
148 It worked! Push the event.
149 """
150+ # We don't get a share_id back from the HTTP REST method
151 if not self.use_http:
152 self.action_queue.event_queue.push('AQ_CREATE_SHARE_OK',
153 share_id=success.share_id,
154
155=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
156--- ubuntuone/syncdaemon/dbus_interface.py 2009-08-26 15:25:50 +0000
157+++ ubuntuone/syncdaemon/dbus_interface.py 2009-09-18 18:41:10 +0000
158@@ -769,6 +769,8 @@
159
160 def emit_share_create_error(self, share_info, error):
161 """ emits ShareDeleted signal """
162+ path = self.fs_manager.get_by_mdid(str(share_info['marker'])).path
163+ share_info.update(dict(path=path))
164 self.ShareCreateError(share_info, error)
165
166 @dbus.service.method(DBUS_IFACE_SHARES_NAME,
167
168=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
169--- ubuntuone/syncdaemon/volume_manager.py 2009-09-14 19:03:00 +0000
170+++ ubuntuone/syncdaemon/volume_manager.py 2009-09-18 18:41:10 +0000
171@@ -418,7 +418,7 @@
172 self.log.debug('create share(%r, %s, %s, %s)',
173 path, username, name, access_level)
174 mdobj = self.m.fs.get_by_path(path)
175- mdid = self.m.fs.get_by_node_id(mdobj.share_id, mdobj.node_id)
176+ mdid = mdobj.mdid
177 marker = MDMarker(mdid)
178 share = Share(self.m.fs.get_abspath("", mdobj.path), share_id=marker,
179 name=name, access_level=access_level,

Subscribers

People subscribed via source and target branches