Merge lp:~lucio.torre/ubuntuone-client/dont-reorder-deletes-stable into lp:ubuntuone-client

Proposed by Lucio Torre
Status: Rejected
Rejected by: Lucio Torre
Proposed branch: lp:~lucio.torre/ubuntuone-client/dont-reorder-deletes-stable
Merge into: lp:ubuntuone-client
Diff against target: 500 lines (+418/-11) (has conflicts)
3 files modified
nautilus/ubuntuone-nautilus.c (+410/-0)
tests/syncdaemon/test_sync.py (+7/-2)
ubuntuone/syncdaemon/sync.py (+1/-9)
Text conflict in nautilus/ubuntuone-nautilus.c
To merge this branch: bzr merge lp:~lucio.torre/ubuntuone-client/dont-reorder-deletes-stable
Reviewer Review Type Date Requested Status
dobey (community) Needs Resubmitting
Review via email: mp+36457@code.launchpad.net

Description of the change

make sure we dont reorder deletes
with this change the conflict is avoided and integration tests pass
i dont know why this was done this way the first time.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Looks like you pulled the wrong code, and committed some conflicts.

8 +<<<<<<< TREE
9 +=======

review: Needs Resubmitting

Unmerged revisions

717. By Lucio Torre

merged changes

716. By Roman Yepishev

Reuse shared structure to avoid crashes due to referencing already released memory.

715. By John Lenton

correctly stringify http errors that occur in restclient (in another process), and fix the call to bus.get_object in the case of removing the current machine's token.

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 2010-09-23 13:37:34 +0000
3+++ nautilus/ubuntuone-nautilus.c 2010-09-23 15:17:41 +0000
4@@ -328,6 +328,142 @@
5 iface->get_widget = ubuntuone_nautilus_get_location_widget;
6 }
7
8+<<<<<<< TREE
9+=======
10+static void __cb_data_free (struct _CBData * data, gboolean destroy) {
11+ if (!data)
12+ return;
13+
14+ data->uon = NULL;
15+ data->parent = NULL;
16+ data->make_public = FALSE;
17+
18+ if (data->path) {
19+ g_free (data->path);
20+ data->path = NULL;
21+ }
22+
23+ if (destroy) {
24+ g_free (data);
25+ data = NULL;
26+ }
27+
28+}
29+
30+/* Menu callbacks */
31+static void ubuntuone_nautilus_public_meta (SyncdaemonFilesystemInterface *interface,
32+ gboolean success,
33+ SyncdaemonMetadata *metadata,
34+ gpointer user_data) {
35+ struct _CBData * data = (struct _CBData *) user_data;
36+ GError * error = NULL;
37+ const gchar * share_id, * node_id;
38+ SyncdaemonInterface *public;
39+
40+ if (!success) {
41+ g_warning ("ERROR: getting metadata for public file");
42+ return;
43+ }
44+
45+ share_id = syncdaemon_metadata_get_share_id (metadata);
46+ node_id = syncdaemon_metadata_get_node_id (metadata);
47+
48+ public = syncdaemon_daemon_get_publicfiles_interface (data->uon->syncdaemon);
49+ if (public != NULL) {
50+ syncdaemon_publicfiles_interface_change_public_access (SYNCDAEMON_PUBLICFILES_INTERFACE (public),
51+ share_id, node_id, data->make_public);
52+ }
53+}
54+
55+static void ubuntuone_nautilus_unsubscribe_folder (NautilusMenuItem *item,
56+ gpointer user_data) {
57+ SyncdaemonInterface *interface;
58+ struct _CBData * data = (struct _CBData *) user_data;
59+
60+ /* Perform the removal of this folder */
61+ interface = syncdaemon_daemon_get_folders_interface (data->uon->syncdaemon);
62+ if (interface != NULL) {
63+ SyncdaemonFolderInfo *folder_info;
64+
65+ folder_info = syncdaemon_folders_interface_get_info (SYNCDAEMON_FOLDERS_INTERFACE (interface),
66+ data->path);
67+ if (folder_info != NULL) {
68+ if (ubuntuone_nautilus_check_shares_and_public_files (data->uon, folder_info, data->parent)) {
69+ syncdaemon_folders_interface_delete (SYNCDAEMON_FOLDERS_INTERFACE (interface),
70+ syncdaemon_folder_info_get_volume_id (folder_info));
71+ }
72+ g_object_unref (G_OBJECT (folder_info));
73+ }
74+ }
75+}
76+
77+static void ubuntuone_nautilus_subscribe_folder (NautilusMenuItem *item,
78+ gpointer user_data) {
79+ SyncdaemonInterface *interface;
80+ struct _CBData * data = (struct _CBData *) user_data;
81+
82+ /* Perform the addition of this folder */
83+ interface = syncdaemon_daemon_get_folders_interface (data->uon->syncdaemon);
84+ if (interface != NULL) {
85+ /* If there is no user authenticated, make Syncdaemon do so */
86+ if (!syncdaemon_authentication_has_credentials (syncdaemon_daemon_get_authentication (data->uon->syncdaemon)))
87+ syncdaemon_daemon_connect (data->uon->syncdaemon);
88+ syncdaemon_folders_interface_create (SYNCDAEMON_FOLDERS_INTERFACE (interface),
89+ data->path);
90+ }
91+}
92+
93+static void ubuntuone_nautilus_copy_public_url (NautilusMenuItem * item,
94+ gpointer user_data) {
95+ struct _CBData * data = (struct _CBData *) user_data;
96+ gchar * url;
97+
98+ url = g_hash_table_lookup (data->uon->public, data->path);
99+ gtk_clipboard_set_text (gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
100+ url, strlen (url));
101+ gtk_clipboard_store (gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
102+}
103+
104+static void ubuntuone_nautilus_toggle_publicity (NautilusMenuItem * item,
105+ gpointer user_data) {
106+ SyncdaemonFilesystemInterface *interface;
107+ struct _CBData * data = (struct _CBData *) user_data;
108+
109+ interface = (SyncdaemonFilesystemInterface *) syncdaemon_daemon_get_filesystem_interface (data->uon->syncdaemon);
110+ if (interface != NULL) {
111+ /* we know this will not be a directory (so no need for _and_quick_tree_synced) */
112+ syncdaemon_filesystem_interface_get_metadata_async (interface, data->path, FALSE,
113+ (SyncdaemonGotMetadataFunc) ubuntuone_nautilus_public_meta,
114+ data);
115+ }
116+
117+ g_hash_table_replace (data->uon->public, g_strdup (data->path), UPDATE_PENDING);
118+ ubuntuone_nautilus_reset_emblem (data->uon, data->path);
119+}
120+
121+static void ubuntuone_nautilus_share_folder (NautilusMenuItem * item,
122+ gpointer * user_data) {
123+ struct _CBData * data = (struct _CBData *) user_data;
124+ GtkWidget * dialog;
125+
126+ dialog = share_dialog_new (data->parent, data->uon, data->path);
127+ gtk_widget_show (dialog);
128+}
129+
130+static void ubuntuone_nautilus_unshare_folder (NautilusMenuItem * item,
131+ gpointer * user_data) {
132+ struct _CBData * data = (struct _CBData *) user_data;
133+ gchar * share_id;
134+ SyncdaemonSharesInterface *interface;
135+
136+ interface = (SyncdaemonSharesInterface *) syncdaemon_daemon_get_shares_interface (data->uon->syncdaemon);
137+ if (interface != NULL) {
138+ share_id = g_hash_table_lookup (data->uon->shares, data->path);
139+ syncdaemon_shares_interface_delete (interface, share_id);
140+ }
141+}
142+
143+>>>>>>> MERGE-SOURCE
144 /* Menu provider */
145 static GList *
146 ubuntuone_nautilus_get_menu_items (NautilusMenuProvider * provider,
147@@ -335,8 +471,20 @@
148 GList * files)
149 {
150 UbuntuOneNautilus * uon;
151+<<<<<<< TREE
152 GList *items = NULL;
153 NautilusMenuItem *root_item;
154+=======
155+ NautilusFileInfo * file;
156+ NautilusMenu * submenu;
157+ NautilusMenuItem * root_item;
158+ GList * items = NULL;
159+ gchar * path;
160+ gchar * item;
161+ gchar * homedir_path;
162+ gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
163+ gboolean is_inhome, is_dir, is_regular;
164+>>>>>>> MERGE-SOURCE
165
166 uon = UBUNTUONE_NAUTILUS (provider);
167
168@@ -344,9 +492,266 @@
169 if (!syncdaemon_daemon_is_ready (uon->syncdaemon))
170 return NULL;
171
172+<<<<<<< TREE
173 root_item = context_menu_new (uon, window, files);
174 if (root_item != NULL)
175 items = g_list_append (items, root_item);
176+=======
177+ is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
178+ is_inhome = is_dir = is_regular = FALSE;
179+
180+ if (g_list_length (files) != 1)
181+ return NULL;
182+
183+ file = g_list_nth_data (files, 0);
184+ path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);
185+
186+ if (path == NULL)
187+ goto done;
188+
189+ if (ubuntuone_is_storagefs (uon, path, &is_root))
190+ is_managed = TRUE;
191+
192+ homedir_path = g_strdup_printf ("%s/", g_get_home_dir());
193+ if (strncmp (path, homedir_path, strlen (homedir_path)) == 0)
194+ is_inhome = TRUE;
195+ g_free (homedir_path);
196+
197+ if ((item = g_hash_table_lookup (uon->udfs, path)) != NULL) {
198+ is_udf = TRUE;
199+ if (strcmp (item, UPDATE_PENDING) == 0)
200+ is_pending = TRUE;
201+ } else if ((item = g_hash_table_lookup (uon->public, path)) != NULL) {
202+ is_public = TRUE;
203+ if (strcmp (item, UPDATE_PENDING) == 0)
204+ is_pending = TRUE;
205+ }
206+ if (g_hash_table_lookup (uon->shares, path) != NULL)
207+ is_shared = TRUE;
208+
209+ is_dir = nautilus_file_info_is_directory (file);
210+ is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;
211+
212+ /* Create new structure only if it does not already exist */
213+ if (uon->cb_data)
214+ __cb_data_free (uon->cb_data, FALSE);
215+ else
216+ uon->cb_data = g_new0 (struct _CBData, 1);
217+
218+ uon->cb_data->uon = uon;
219+ uon->cb_data->parent = window;
220+ uon->cb_data->path = g_strdup (path);
221+
222+ root_item = nautilus_menu_item_new ("ubuntuone",
223+ _("_Ubuntu One"),
224+ _("Ubuntu One options"),
225+ "ubuntuone");
226+ submenu = nautilus_menu_new ();
227+ nautilus_menu_item_set_submenu (root_item, submenu);
228+
229+ items = g_list_append (items, root_item);
230+
231+ /* Share/unshare */
232+ {
233+ NautilusMenuItem * item;
234+
235+ if ((is_managed || is_udf) && !is_root && is_dir) {
236+
237+ item = nautilus_menu_item_new ("ubuntuone-share",
238+ _("_Share..."),
239+ _("Share this folder on Ubuntu One"),
240+ "ubuntuone");
241+ if (is_pending)
242+ g_object_set (item, "sensitive", FALSE, NULL);
243+
244+ g_signal_connect (item, "activate",
245+ G_CALLBACK (ubuntuone_nautilus_share_folder),
246+ uon->cb_data);
247+ } else {
248+ /* the different tooltips will probably do us no good */
249+ if (is_root) {
250+ item = nautilus_menu_item_new ("ubuntuone-noshare-root",
251+ _("_Share..."),
252+ _("Sorry, you can't share the root of a Ubuntu One volume"),
253+ "ubuntuone");
254+ } else if (!(is_managed || is_udf)) {
255+ item = nautilus_menu_item_new ("ubuntuone-noshare-unmanaged",
256+ _("_Share..."),
257+ _("Sorry, you can't share folders not managed by Ubuntu One"),
258+ "ubuntuone");
259+ } else {
260+ item = nautilus_menu_item_new ("ubuntuone-noshare-unmanaged",
261+ _("_Share..."),
262+ _("Sorry, you can only share folders"),
263+ "ubuntuone");
264+ }
265+ g_object_set (item, "sensitive", FALSE, NULL);
266+ }
267+
268+ nautilus_menu_append_item (submenu, item);
269+ }
270+
271+ if ((is_managed && is_shared) && !is_root && is_dir) {
272+ NautilusMenuItem * item;
273+
274+ item = nautilus_menu_item_new ("ubuntuone-unshare",
275+ _("Stop _Sharing"),
276+ _("Stop sharing this folder on Ubuntu One"),
277+ "ubuntuone");
278+ if (is_pending)
279+ g_object_set (item, "sensitive", FALSE, NULL);
280+
281+ g_signal_connect (item, "activate",
282+ G_CALLBACK (ubuntuone_nautilus_unshare_folder),
283+ uon->cb_data);
284+ nautilus_menu_append_item (submenu, item);
285+ }
286+
287+ {
288+ /* UDF logic
289+ *
290+ * XXX: clean this up and separate the logic out and reuse this
291+ * and locationbar somewhere (libsd?)
292+ */
293+ NautilusMenuItem * item = NULL;
294+ if (is_dir && is_inhome) {
295+ /* UDFs could be happening */
296+ if (is_managed) {
297+ if (strcmp (path, uon->managed) == 0) {
298+ /* the Ubuntu One directory, no UDFs */
299+ item = nautilus_menu_item_new ("ubuntuone-no-disable-u1",
300+ _("Stop Synchronizing This _Folder"),
301+ _("Sorry, you can't stop synchronizing ~/Ubuntu One"),
302+ "ubuntuone");
303+ g_object_set (item, "sensitive", FALSE, NULL);
304+ } else if (is_root) {
305+ /* the root of a UDF: disabling possible */
306+
307+ item = nautilus_menu_item_new ("ubuntuone-disable-udf",
308+ _("Stop Synchronizing This _Folder"),
309+ _("Stop synchronizing this folder with Ubuntu One"),
310+ "ubuntuone");
311+
312+ g_signal_connect (item, "activate",
313+ G_CALLBACK (ubuntuone_nautilus_unsubscribe_folder),
314+ uon->cb_data);
315+ }
316+ } else {
317+ /* unmanaged */
318+
319+ item = nautilus_menu_item_new ("ubuntuone-enable-udf",
320+ _("Synchronize This _Folder"),
321+ _("Start synchronizing this folder with Ubuntu One"),
322+ "ubuntuone");
323+
324+ g_signal_connect (item, "activate",
325+ G_CALLBACK (ubuntuone_nautilus_subscribe_folder),
326+ uon->cb_data);
327+ }
328+ } else {
329+ if (is_dir) {
330+ item = nautilus_menu_item_new ("ubuntuone-no-disable-u1",
331+ _("Synchronize This _Folder"),
332+ _("Sorry, you can only synchronize folders within your home folder"),
333+ "ubuntuone");
334+ } else {
335+ item = nautilus_menu_item_new ("ubuntuone-no-disable-u1",
336+ _("Synchronize This _Folder"),
337+ _("Sorry, you can only synchronize folders"),
338+ "ubuntuone");
339+ }
340+ g_object_set (item, "sensitive", FALSE, NULL);
341+ }
342+ if (!item) {
343+ item = nautilus_menu_item_new ("ubuntuone-no-udf-operation-possible",
344+ _("Synchronize This _Folder"),
345+ _("Synchronization not possible for this folder"),
346+ "ubuntuone");
347+ g_object_set (item, "sensitive", FALSE, NULL);
348+ }
349+ nautilus_menu_append_item (submenu, item);
350+ }
351+
352+ /* public files */
353+ {
354+ NautilusMenuItem * item = NULL, * urlitem = NULL;
355+
356+ if (is_managed && is_regular) {
357+
358+ if (is_public) {
359+ urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
360+ _("Copy Web _Link"),
361+ _("Copy the Ubuntu One public URL for this file to the clipboard."),
362+ "ubuntuone");
363+ if (is_pending)
364+ g_object_set (urlitem, "sensitive", FALSE, NULL);
365+
366+ g_signal_connect (urlitem, "activate",
367+ G_CALLBACK (ubuntuone_nautilus_copy_public_url),
368+ uon->cb_data);
369+ item = nautilus_menu_item_new ("ubuntuone-unpublish",
370+ _("Stop _Publishing"),
371+ _("No longer share this file with everyone via Ubuntu One."),
372+ "ubuntuone");
373+ if (is_pending)
374+ g_object_set (item, "sensitive", FALSE, NULL);
375+
376+ uon->cb_data->make_public = FALSE;
377+ } else {
378+ item = nautilus_menu_item_new ("ubuntuone-publish",
379+ _("_Publish"),
380+ _("Make this file available to anyone via Ubuntu One."),
381+ "ubuntuone");
382+ uon->cb_data->make_public = TRUE;
383+ }
384+ g_signal_connect (item, "activate",
385+ G_CALLBACK (ubuntuone_nautilus_toggle_publicity),
386+ uon->cb_data);
387+ }
388+ if (!urlitem) {
389+ urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
390+ _("Copy Web _Link"),
391+ _("Sorry, no public URL for this file via Ubuntu One."),
392+ "ubuntuone");
393+ g_object_set (urlitem, "sensitive", FALSE, NULL);
394+ }
395+ if (!item) {
396+ item = nautilus_menu_item_new ("ubuntuone-publish",
397+ _("_Publish"),
398+ _("Sorry, unable to publish via Ubuntu One."),
399+ "ubuntuone");
400+ g_object_set (item, "sensitive", FALSE, NULL);
401+ }
402+
403+ nautilus_menu_append_item (submenu, item);
404+ nautilus_menu_append_item (submenu, urlitem);
405+ }
406+
407+ /* location bar enable/disable */
408+ {
409+ NautilusMenuItem * item;
410+ if (show_location()) {
411+ item = nautilus_menu_item_new ("ubuntuone-location-hide",
412+ _("Hide _Ribbon"),
413+ _("Do not show the Ubuntu One ribbon"
414+ " in selected folders"),
415+ "ubuntuone");
416+ } else {
417+ item = nautilus_menu_item_new ("ubuntuone-location-show",
418+ _("Show _Ribbon in Some Folders"),
419+ _("Show the Ubuntu One ribbon"
420+ " in selected folders"),
421+ "ubuntuone");
422+ }
423+ g_signal_connect (item, "activate",
424+ G_CALLBACK (toggle_location),
425+ uon->cb_data);
426+ nautilus_menu_append_item (submenu, item);
427+ }
428+
429+ done:
430+ g_free (path);
431+>>>>>>> MERGE-SOURCE
432
433 return items;
434 }
435@@ -439,6 +844,11 @@
436 static void ubuntuone_nautilus_finalize(GObject * object) {
437 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS(object);
438
439+<<<<<<< TREE
440+=======
441+ __cb_data_free (uon->cb_data, TRUE);
442+
443+>>>>>>> MERGE-SOURCE
444 if (uon->syncdaemon)
445 g_object_unref (uon->syncdaemon);
446
447
448=== modified file 'tests/syncdaemon/test_sync.py'
449--- tests/syncdaemon/test_sync.py 2010-09-15 19:02:52 +0000
450+++ tests/syncdaemon/test_sync.py 2010-09-23 15:17:41 +0000
451@@ -1349,7 +1349,12 @@
452 self.handler.records = []
453
454 def test_handle_deletes_last(self):
455- """The handler for SV_FILE_DELETED is called last"""
456+ """The handler for SV_FILE_DELETED is not called last
457+
458+ If we reorder deletes we will get a fake conflict when a
459+ delete and move that overwrites the deleted file arrives.
460+ """
461+
462 self.create_filetxt()
463 self.create_dir()
464
465@@ -1373,7 +1378,7 @@
466 self.sync.handle_AQ_DELTA_OK(**kwargs)
467
468 # check that the handlers are called in order
469- self.assertEqual(called, ['hash', 'delete'])
470+ self.assertEqual(called, ['delete', 'hash'])
471
472 def test_exception_mark_node_as_dirty(self):
473 """We mark the node as dirty and send an event on error."""
474
475=== modified file 'ubuntuone/syncdaemon/sync.py'
476--- ubuntuone/syncdaemon/sync.py 2010-09-15 19:02:52 +0000
477+++ ubuntuone/syncdaemon/sync.py 2010-09-23 15:17:41 +0000
478@@ -1077,6 +1077,7 @@
479 # about it
480 if not dt.is_live:
481 to_delete.append(dt)
482+ self._handle_SV_FILE_DELETED(dt.share_id, dt.node_id)
483 # nothing else should happen with this
484 continue
485
486@@ -1146,15 +1147,6 @@
487 "Node delta for %s:%s can't be applied.",
488 dt.share_id, dt.node_id)
489
490- for dt in to_delete:
491- try:
492- # delete all the nodes after applying all deltas
493- self._handle_SV_FILE_DELETED(dt.share_id, dt.node_id)
494- except Exception:
495- self.logger.exception(
496- "Node delete for %s:%s can't be applied.",
497- dt.share_id, dt.node_id)
498-
499 # And mark the node as dirty
500 self.mark_node_as_dirty(dt.share_id, dt.node_id)
501

Subscribers

People subscribed via source and target branches