Merge ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-fix-file-remote-type-search-crash into ~ubuntu-desktop/ubuntu/+source/nautilus:ubuntu/bionic

Proposed by Marco Trevisan (Treviño) on 2018-09-28
Status: Superseded
Proposed branch: ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-fix-file-remote-type-search-crash
Merge into: ~ubuntu-desktop/ubuntu/+source/nautilus:ubuntu/bionic
Prerequisite: ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-xubuntu-cancel-search
Diff against target: 439 lines (+136/-222)
8 files modified
debian/changelog (+4/-5)
debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch (+1/-1)
debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch (+1/-1)
debian/patches/0018-search-engine-add-locate-based-search-engine.patch (+1/-1)
debian/patches/query-add-recursive-flags-and-use-it-in-search-engines.patch (+1/-1)
debian/patches/search-engine-Query-file-system-to-determine-remoteness.patch (+127/-0)
debian/patches/series (+1/-1)
dev/null (+0/-212)
Reviewer Review Type Date Requested Status
Ubuntu Desktop 2018-09-28 Pending
Review via email: mp+355859@code.launchpad.net

This proposal supersedes a proposal from 2018-09-28.

This proposal has been superseded by a proposal from 2018-10-04.

To post a comment you must log in.
fde29bc... by Marco Trevisan (Treviño) on 2018-10-04

Finalise changelog

Unmerged commits

fde29bc... by Marco Trevisan (Treviño) on 2018-10-04

Finalise changelog

43a23ec... by Marco Trevisan (Treviño) on 2018-09-28

d/p/search-engine-Query-file-system-to-determine-remoteness.patch

Cherry-pick remote filesystem check on file during search.

Fixes LP: #1795028

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 312bb43..1d1673f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,10 +1,9 @@
6-nautilus (1:3.26.4-0~ubuntu18.04.2) UNRELEASED; urgency=medium
7+nautilus (1:3.26.4-0~ubuntu18.04.2) bionic; urgency=medium
8
9- * d/p/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch:
10- shell-search-provider: implement XUbuntuCancel to request pending
11- search cancellation from gnome-shell (LP: #1756826)
12+ * d/p/search-engine-Query-file-system-to-determine-remoteness.patch:
13+ - Fix remote filesystem check on file during search (LP: #1795028)
14
15- -- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 05 Sep 2018 18:03:14 +0200
16+ -- Marco Trevisan (Treviño) <marco@ubuntu.com> Thu, 04 Oct 2018 16:15:08 +0200
17
18 nautilus (1:3.26.4-0~ubuntu18.04.1) bionic; urgency=medium
19
20diff --git a/debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch b/debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch
21index f80997f..20e597c 100644
22--- a/debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch
23+++ b/debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch
24@@ -512,7 +512,7 @@ index 0000000..bcd73b9
25 +
26 +#endif /* __NAUTILUS_SEARCH_ENGINE_RECENT_H__ */
27 diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c
28-index 3a0c9d4..793b831 100644
29+index 28863f7..a4c6007 100644
30 --- a/src/nautilus-search-engine.c
31 +++ b/src/nautilus-search-engine.c
32 @@ -30,11 +30,13 @@
33diff --git a/debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch b/debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch
34index e6185da..ad248da 100644
35--- a/debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch
36+++ b/debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch
37@@ -49,7 +49,7 @@ index 19316e8..9bb5460 100644
38
39 /* Now send out the changed and added signals for existing file objects. */
40 diff --git a/src/nautilus-file.c b/src/nautilus-file.c
41-index 63413a6..9416214 100644
42+index 28b5a13..7886d1f 100644
43 --- a/src/nautilus-file.c
44 +++ b/src/nautilus-file.c
45 @@ -34,6 +34,7 @@
46diff --git a/debian/patches/0018-search-engine-add-locate-based-search-engine.patch b/debian/patches/0018-search-engine-add-locate-based-search-engine.patch
47index 91a7ec0..158b448 100644
48--- a/debian/patches/0018-search-engine-add-locate-based-search-engine.patch
49+++ b/debian/patches/0018-search-engine-add-locate-based-search-engine.patch
50@@ -678,7 +678,7 @@ index 0000000..ac5e3fc
51 +
52 +#endif /* __NAUTILUS_SEARCH_ENGINE_LOCATE_H__ */
53 diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c
54-index 793b831..902d483 100644
55+index a4c6007..475a432 100644
56 --- a/src/nautilus-search-engine.c
57 +++ b/src/nautilus-search-engine.c
58 @@ -29,6 +29,7 @@
59diff --git a/debian/patches/query-add-recursive-flags-and-use-it-in-search-engines.patch b/debian/patches/query-add-recursive-flags-and-use-it-in-search-engines.patch
60index fddae3e..3c89693 100644
61--- a/debian/patches/query-add-recursive-flags-and-use-it-in-search-engines.patch
62+++ b/debian/patches/query-add-recursive-flags-and-use-it-in-search-engines.patch
63@@ -198,7 +198,7 @@ index b567611..b165d63 100644
64 +
65 #endif /* NAUTILUS_FILE_UTILITIES_H */
66 diff --git a/src/nautilus-file.c b/src/nautilus-file.c
67-index 3f6a69f..63413a6 100644
68+index 22ea199..e30d791 100644
69 --- a/src/nautilus-file.c
70 +++ b/src/nautilus-file.c
71 @@ -4975,6 +4975,29 @@ nautilus_file_get_filesystem_type (NautilusFile *file)
72diff --git a/debian/patches/search-engine-Query-file-system-to-determine-remoteness.patch b/debian/patches/search-engine-Query-file-system-to-determine-remoteness.patch
73new file mode 100644
74index 0000000..1b7f874
75--- /dev/null
76+++ b/debian/patches/search-engine-Query-file-system-to-determine-remoteness.patch
77@@ -0,0 +1,127 @@
78+From: Ernestas Kulik <ernestask@gnome.org>
79+Date: Fri, 14 Sep 2018 12:52:11 +0200
80+Subject: search-engine: Query file system to determine remoteness
81+
82+Querying the file cache in is_recursive_search() does not guarantee that
83+the file system field will be populated with a value, and somehow
84+results in data races, in turn resulting in random crashes/file list
85+corruption.
86+
87+Hopefully fixes https://gitlab.gnome.org/GNOME/nautilus/issues/640,
88+closes https://gitlab.gnome.org/GNOME/nautilus/issues/632 and resolves
89+https://gitlab.gnome.org/GNOME/nautilus/issues/602
90+
91+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1795028
92+Applied-Upstream: yes, 3.30.1, https://gitlab.gnome.org/GNOME/nautilus/commit/62ba6d83d
93+---
94+ src/nautilus-file-utilities.c | 18 ++++++++++++++++++
95+ src/nautilus-file-utilities.h | 2 ++
96+ src/nautilus-file.c | 14 +-------------
97+ src/nautilus-search-engine.c | 18 +++++++++++++++---
98+ 4 files changed, 36 insertions(+), 16 deletions(-)
99+
100+diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
101+index f8d8476..3e363a4 100644
102+--- a/src/nautilus-file-utilities.c
103++++ b/src/nautilus-file-utilities.c
104+@@ -1565,3 +1565,21 @@ location_settings_search_get_recursive_for_location (GFile *location)
105+
106+ return recursive;
107+ }
108++
109++gboolean
110++nautilus_file_system_is_remote (const char *file_system)
111++{
112++ static const gchar * const remote_types[] =
113++ {
114++ "afp",
115++ "google-drive",
116++ "sftp",
117++ "webdav",
118++ "ftp",
119++ "nfs",
120++ "cifs",
121++ NULL
122++ };
123++
124++ return file_system != NULL && g_strv_contains (remote_types, file_system);
125++}
126+diff --git a/src/nautilus-file-utilities.h b/src/nautilus-file-utilities.h
127+index b165d63..37f7f49 100644
128+--- a/src/nautilus-file-utilities.h
129++++ b/src/nautilus-file-utilities.h
130+@@ -133,4 +133,6 @@ gchar * nautilus_uri_to_native_uri (const gchar *uri);
131+ NautilusQueryRecursive location_settings_search_get_recursive (void);
132+ NautilusQueryRecursive location_settings_search_get_recursive_for_location (GFile *location);
133+
134++gboolean nautilus_file_system_is_remote (const char *file_system);
135++
136+ #endif /* NAUTILUS_FILE_UTILITIES_H */
137+diff --git a/src/nautilus-file.c b/src/nautilus-file.c
138+index e30d791..28b5a13 100644
139+--- a/src/nautilus-file.c
140++++ b/src/nautilus-file.c
141+@@ -8371,18 +8371,6 @@ nautilus_file_is_in_recent (NautilusFile *file)
142+ return nautilus_directory_is_in_recent (file->details->directory);
143+ }
144+
145+-static const gchar * const remote_types[] =
146+-{
147+- "afp",
148+- "google-drive",
149+- "sftp",
150+- "webdav",
151+- "ftp",
152+- "nfs",
153+- "cifs",
154+- NULL
155+-};
156+-
157+ /**
158+ * nautilus_file_is_remote
159+ *
160+@@ -8406,7 +8394,7 @@ nautilus_file_is_remote (NautilusFile *file)
161+
162+ filesystem_type = nautilus_file_get_filesystem_type (file);
163+
164+- return filesystem_type != NULL && g_strv_contains (remote_types, filesystem_type);
165++ return nautilus_file_system_is_remote (filesystem_type);
166+ }
167+
168+ /**
169+diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c
170+index 3a0c9d4..28863f7 100644
171+--- a/src/nautilus-search-engine.c
172++++ b/src/nautilus-search-engine.c
173+@@ -23,7 +23,7 @@
174+ #include "nautilus-search-engine.h"
175+ #include "nautilus-search-engine-private.h"
176+
177+-#include "nautilus-file.h"
178++#include "nautilus-file-utilities.h"
179+ #include "nautilus-search-engine-model.h"
180+ #include "nautilus-search-provider.h"
181+ #include <glib/gi18n.h>
182+@@ -437,8 +437,20 @@ is_recursive_search (NautilusSearchEngineType engine_type,
183+
184+ case NAUTILUS_QUERY_RECURSIVE_LOCAL_ONLY:
185+ {
186+- g_autoptr (NautilusFile) file = nautilus_file_get (location);
187+- return !nautilus_file_is_remote (file);
188++ g_autoptr (GFileInfo) file_system_info = NULL;
189++
190++ file_system_info = g_file_query_filesystem_info (location,
191++ G_FILE_ATTRIBUTE_FILESYSTEM_TYPE,
192++ NULL, NULL);
193++ if (file_system_info != NULL)
194++ {
195++ const char *file_system;
196++
197++ file_system = g_file_info_get_attribute_string (file_system_info,
198++ G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
199++
200++ return !nautilus_file_system_is_remote (file_system);
201++ }
202+ }
203+ }
204+
205diff --git a/debian/patches/series b/debian/patches/series
206index 61d3d3a..2942ff8 100644
207--- a/debian/patches/series
208+++ b/debian/patches/series
209@@ -17,6 +17,7 @@ ubuntu_backspace_behaviour.patch
210 #Needs updating
211 #16_unity_new_documents.patch
212 query-add-recursive-flags-and-use-it-in-search-engines.patch
213+search-engine-Query-file-system-to-determine-remoteness.patch
214 0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch
215 0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch
216 0017-recent-add-function-to-update-manager-on-file-rename.patch
217@@ -24,4 +25,3 @@ query-add-recursive-flags-and-use-it-in-search-engines.patch
218 appstream-compulsory.patch
219 nautilusgtkplacesview-show-error-if-volume-is-not-mo.patch
220 file-view-Always-unset-pending_selection-after-freeing-it.patch
221-ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
222diff --git a/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch b/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
223deleted file mode 100644
224index ca55544..0000000
225--- a/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
226+++ /dev/null
227@@ -1,212 +0,0 @@
228-From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
229-Date: Tue, 28 Aug 2018 01:44:49 +0200
230-Subject: shell-search-provider: implement XUbuntuCancel to request search cancellation
231-
232-Stop search and Metadata fetching on XUbuntuCancel dbus method call.
233-Only allow this if the caller is the same who triggered the actual event.
234-
235-Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
236-Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/nautilus/+bug/1756826
237-Forwarded: not-needed
238----
239- data/shell-search-provider-dbus-interfaces.xml | 1 +
240- src/nautilus-shell-search-provider.c | 96 +++++++++++++++++++++++---
241- 2 files changed, 88 insertions(+), 9 deletions(-)
242-
243-diff --git a/data/shell-search-provider-dbus-interfaces.xml b/data/shell-search-provider-dbus-interfaces.xml
244-index f6840e2..4529c1e 100644
245---- a/data/shell-search-provider-dbus-interfaces.xml
246-+++ b/data/shell-search-provider-dbus-interfaces.xml
247-@@ -40,5 +40,6 @@
248- <arg type='as' name='Terms' direction='in' />
249- <arg type='u' name='Timestamp' direction='in' />
250- </method>
251-+ <method name = 'XUbuntuCancel' />
252- </interface>
253- </node>
254-diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
255-index ffc2b7f..58864d6 100644
256---- a/src/nautilus-shell-search-provider.c
257-+++ b/src/nautilus-shell-search-provider.c
258-@@ -60,6 +60,7 @@ struct _NautilusShellSearchProvider
259-
260- PendingSearch *current_search;
261-
262-+ GList *metas_requests;
263- GHashTable *metas_cache;
264- };
265-
266-@@ -143,11 +144,25 @@ pending_search_finish (PendingSearch *search,
267- }
268-
269- static void
270--cancel_current_search (NautilusShellSearchProvider *self)
271-+cancel_current_search (NautilusShellSearchProvider *self,
272-+ gboolean ignore_partial_results)
273- {
274-- if (self->current_search != NULL)
275-+ PendingSearch *search = self->current_search;
276-+
277-+ if (search != NULL)
278- {
279-- nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (self->current_search->engine));
280-+ g_debug ("*** Cancel current search");
281-+
282-+ nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (search->engine));
283-+
284-+ if (ignore_partial_results)
285-+ {
286-+ g_signal_handlers_disconnect_by_data (G_OBJECT (search->engine),
287-+ search);
288-+
289-+ pending_search_finish (search, search->invocation,
290-+ g_variant_new ("(as)", NULL));
291-+ }
292- }
293- }
294-
295-@@ -451,7 +466,7 @@ execute_search (NautilusShellSearchProvider *self,
296- NautilusQuery *query;
297- PendingSearch *pending_search;
298-
299-- cancel_current_search (self);
300-+ cancel_current_search (self, FALSE);
301-
302- /* don't attempt searches for a single character */
303- if (g_strv_length (terms) == 1 &&
304-@@ -524,6 +539,7 @@ typedef struct
305- NautilusShellSearchProvider *self;
306-
307- gint64 start_time;
308-+ NautilusFileListHandle *handle;
309- GDBusMethodInvocation *invocation;
310-
311- gchar **uris;
312-@@ -532,6 +548,8 @@ typedef struct
313- static void
314- result_metas_data_free (ResultMetasData *data)
315- {
316-+ g_clear_pointer (&data->handle, nautilus_file_list_cancel_call_when_ready);
317-+
318- g_clear_object (&data->self);
319- g_clear_object (&data->invocation);
320- g_strfreev (data->uris);
321-@@ -549,7 +567,7 @@ result_metas_return_from_cache (ResultMetasData *data)
322-
323- g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
324-
325-- for (idx = 0; data->uris[idx] != NULL; idx++)
326-+ for (idx = 0; data->uris && data->uris[idx] != NULL; idx++)
327- {
328- meta = g_hash_table_lookup (data->self->metas_cache,
329- data->uris[idx]);
330-@@ -564,6 +582,37 @@ result_metas_return_from_cache (ResultMetasData *data)
331- g_variant_new ("(aa{sv})", &builder));
332- }
333-
334-+static void
335-+cancel_result_meta_requests (NautilusShellSearchProvider *self,
336-+ GDBusMethodInvocation *invocation)
337-+{
338-+ GList *l;
339-+ GList *to_remove = NULL;
340-+
341-+ g_debug ("*** Cancel Results Meta requests");
342-+
343-+ for (l = self->metas_requests; l; l = l->next)
344-+ {
345-+ ResultMetasData *data = l->data;
346-+
347-+ if (invocation == NULL ||
348-+ g_strcmp0 (g_dbus_method_invocation_get_sender (data->invocation),
349-+ g_dbus_method_invocation_get_sender (invocation)) == 0)
350-+ {
351-+ g_clear_pointer (&data->uris, g_strfreev);
352-+ result_metas_return_from_cache (data);
353-+ to_remove = g_list_prepend (to_remove, data);
354-+ }
355-+ }
356-+
357-+ for (l = to_remove; l; l = l->next)
358-+ {
359-+ self->metas_requests = g_list_remove (self->metas_requests, l->data);
360-+ }
361-+
362-+ g_list_free (to_remove);
363-+}
364-+
365- static void
366- result_list_attributes_ready_cb (GList *file_list,
367- gpointer user_data)
368-@@ -639,6 +688,9 @@ result_list_attributes_ready_cb (GList *file_list,
369- g_free (uri);
370- }
371-
372-+ data->handle = NULL;
373-+ data->self->metas_requests = g_list_remove (data->self->metas_requests, data);
374-+
375- result_metas_return_from_cache (data);
376- result_metas_data_free (data);
377- }
378-@@ -682,9 +734,10 @@ handle_get_result_metas (NautilusShellSearchProvider2 *skeleton,
379-
380- nautilus_file_list_call_when_ready (missing_files,
381- NAUTILUS_FILE_ATTRIBUTES_FOR_ICON,
382-- NULL,
383-+ &data->handle,
384- result_list_attributes_ready_cb,
385- data);
386-+ self->metas_requests = g_list_prepend (self->metas_requests, data);
387- nautilus_file_list_free (missing_files);
388- return TRUE;
389- }
390-@@ -743,14 +796,37 @@ handle_launch_search (NautilusShellSearchProvider2 *skeleton,
391- return TRUE;
392- }
393-
394--static void
395--search_provider_dispose (GObject *obj)
396-+static gboolean
397-+handle_xubuntu_cancel (NautilusShellSearchProvider2 *skeleton,
398-+ GDBusMethodInvocation *invocation,
399-+ gpointer user_data)
400- {
401-+ NautilusShellSearchProvider *self = user_data;
402-+ PendingSearch *search = self->current_search;
403-+
404-+ g_debug ("*** XUbuntuCancel called");
405-+
406-+ if (search != NULL &&
407-+ g_strcmp0 (g_dbus_method_invocation_get_sender (search->invocation),
408-+ g_dbus_method_invocation_get_sender (invocation)) == 0)
409-+ {
410-+ cancel_current_search (self, TRUE);
411-+ }
412-+
413-+ cancel_result_meta_requests (self, invocation);
414-+
415-+ nautilus_shell_search_provider2_complete_xubuntu_cancel (skeleton, invocation);
416-+
417-+ return TRUE;
418-+}
419-+
420-+ static void search_provider_dispose(GObject * obj) {
421- NautilusShellSearchProvider *self = NAUTILUS_SHELL_SEARCH_PROVIDER (obj);
422-
423- g_clear_object (&self->skeleton);
424- g_hash_table_destroy (self->metas_cache);
425-- cancel_current_search (self);
426-+ cancel_current_search (self, TRUE);
427-+ cancel_result_meta_requests (self, NULL);
428-
429- G_OBJECT_CLASS (nautilus_shell_search_provider_parent_class)->dispose (obj);
430- }
431-@@ -773,6 +849,8 @@ nautilus_shell_search_provider_init (NautilusShellSearchProvider *self)
432- G_CALLBACK (handle_activate_result), self);
433- g_signal_connect (self->skeleton, "handle-launch-search",
434- G_CALLBACK (handle_launch_search), self);
435-+ g_signal_connect (self->skeleton, "handle-xubuntu-cancel",
436-+ G_CALLBACK (handle_xubuntu_cancel), self);
437- }
438-
439- static void

Subscribers

People subscribed via source and target branches