Merge lp:~ralsina/ubuntuone-client/fix_712674_on_1.4 into lp:ubuntuone-client/stable-1-4

Proposed by Roberto Alsina
Status: Merged
Approved by: Roman Yepishev
Approved revision: 751
Merged at revision: 748
Proposed branch: lp:~ralsina/ubuntuone-client/fix_712674_on_1.4
Merge into: lp:ubuntuone-client/stable-1-4
Diff against target: 86 lines (+37/-4)
1 file modified
nautilus/ubuntuone-nautilus.c (+37/-4)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-client/fix_712674_on_1.4
Reviewer Review Type Date Requested Status
Roman Yepishev (community) fieldtest Approve
dobey (community) Approve
Review via email: mp+49460@code.launchpad.net

Commit message

Don't offer the "Publish" option in the context menu for files/folders that are being shared to the user, because it's not supported.

Description of the change

Adds a utility function to determine if a file or directory is inside a share, and uses that to modify the context menu so you can't try to publish those files/directories.

To fieldtest it, build it using these commands:

WARNING, this overwrites part of ubuntuone-client-gnome, you may need to reinstall it later

./autogen.sh
./configure --prefix=/usr
make
cd nautilus && sudo make install
pkill nautilus
nautilus nautilus ~/Ubuntu\ One/Shared\ With\ Me/

Then check the context menus, the "Ubuntu One->Publish" option should be disabled.
Check also in a subdirectory, with folders and files, and that the Publish option is enabled for contents outside the shares.

To post a comment you must log in.
750. By Roberto Alsina

mark the bug this fixes

Revision history for this message
dobey (dobey) wrote :

54 +
55 +
56 +
57 +

85 +
86 +
87 +

What are all the extra blank lines being added for?

review: Needs Information
Revision history for this message
Roberto Alsina (ralsina) wrote :

> 54 +
> 55 +
> 56 +
> 57 +
>
> 85 +
> 86 +
> 87 +
>
> What are all the extra blank lines being added for?

No reason, I'll remove them.

751. By Roberto Alsina

remove empty lines

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Roman Yepishev (rye) wrote :

Yep, no publish in shares.

review: Approve (fieldtest)

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-12-07 22:00:23 +0000
3+++ nautilus/ubuntuone-nautilus.c 2011-02-14 14:39:13 +0000
4@@ -24,7 +24,7 @@
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8-
9+#include <stdlib.h>
10 #include <glib/gi18n-lib.h>
11 #include <libnautilus-extension/nautilus-extension-types.h>
12 #include <libnautilus-extension/nautilus-file-info.h>
13@@ -163,6 +163,36 @@
14
15 }
16
17+/*
18+ * Check if the passed folder is inside a folder shared TO the user.
19+ *
20+ * Added to fix bug #712674
21+ */
22+gboolean
23+ubuntuone_is_inside_shares (UbuntuOneNautilus *uon, const gchar *path)
24+{
25+ gboolean is_shared_to_me = FALSE;
26+ gchar *resolved_path;
27+ gchar *prefix = g_build_filename (g_get_user_data_dir (), "ubuntuone", "shares", G_DIR_SEPARATOR_S, NULL);
28+
29+ /*
30+ * Have to use realpath because path contains a symlink like
31+ * ~/Ubuntu One/Shared With Me -> ~/.local/share/ubuntuone/shares
32+ *
33+ * This also claims ~/Ubuntu One/Shared with Me/foo is
34+ * in a share even if it's not true. that's intentional since
35+ * those files are never uploaded, and thus it makes no sense
36+ * to publish them.
37+ */
38+ resolved_path = realpath(path, NULL);
39+ if (g_str_has_prefix (resolved_path, prefix)) {
40+ is_shared_to_me = TRUE;
41+ }
42+ free (resolved_path);
43+ g_free (prefix);
44+ return is_shared_to_me;
45+}
46+
47 /* Are we in an Ubuntu One managed (root or udf) directory */
48 gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,
49 const char * path,
50@@ -524,7 +554,7 @@
51 gchar * item;
52 gchar * homedir_path;
53 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
54- gboolean is_inhome, is_dir, is_regular;
55+ gboolean is_shared_to_me, is_inhome, is_dir, is_regular;
56
57 uon = UBUNTUONE_NAUTILUS (provider);
58
59@@ -533,7 +563,7 @@
60 return NULL;
61
62 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
63- is_inhome = is_dir = is_regular = FALSE;
64+ is_shared_to_me = is_inhome = is_dir = is_regular = FALSE;
65
66 if (g_list_length (files) != 1)
67 return NULL;
68@@ -547,6 +577,9 @@
69 if (ubuntuone_is_storagefs (uon, path, &is_root))
70 is_managed = TRUE;
71
72+ if (ubuntuone_is_inside_shares (uon, path))
73+ is_shared_to_me = TRUE;
74+
75 homedir_path = g_strdup_printf ("%s/", g_get_home_dir());
76 if (strncmp (path, homedir_path, strlen (homedir_path)) == 0)
77 is_inhome = TRUE;
78@@ -711,7 +744,7 @@
79 {
80 NautilusMenuItem * item = NULL, * urlitem = NULL;
81
82- if (is_managed && is_regular) {
83+ if (!is_shared_to_me && is_managed && is_regular) {
84
85 if (is_public) {
86 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",

Subscribers

People subscribed via source and target branches