diff options
author | Carlos Soriano <csoriano@gnome.org> | 2015-09-01 19:21:11 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2015-09-02 20:29:30 +0200 |
commit | d3e1a71c6377343af5d61d6ded7bc4f53dfeaf53 (patch) | |
tree | 220ef0fe04524891c61fbe256297abc524d7b7f3 | |
parent | 70fbae08fee1beee9ae4a352b05fe041610173b7 (diff) | |
download | nautilus-d3e1a71c6377343af5d61d6ded7bc4f53dfeaf53.tar.gz |
search: don't search recursively on network locations
It's too slow to search recursively on locations that are on the
network. For that case, just search in the current folder.
https://bugzilla.gnome.org/show_bug.cgi?id=725939
-rw-r--r-- | libnautilus-private/nautilus-directory.c | 30 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory.h | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.c | 6 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.h | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-search-directory.c | 8 | ||||
-rw-r--r-- | src/nautilus-files-view.c | 6 |
6 files changed, 42 insertions, 12 deletions
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c index e150e8106..fad84c9b5 100644 --- a/libnautilus-private/nautilus-directory.c +++ b/libnautilus-private/nautilus-directory.c @@ -601,17 +601,41 @@ nautilus_directory_is_in_recent (NautilusDirectory *directory) return g_file_has_uri_scheme (directory->details->location, "recent"); } +static const gchar * const remote_types[] = { + "sftp", + "webdav", + "ftp", + "nfs", + "cifs", + NULL +}; + gboolean -nautilus_directory_is_in_network (NautilusDirectory *directory) +nautilus_directory_is_remote (NautilusDirectory *directory) { + GFileInfo *info; + gboolean is_remote; + g_assert (NAUTILUS_IS_DIRECTORY (directory)); if (directory->details->location == NULL) { return FALSE; } - return g_file_has_uri_scheme (directory->details->location, "network") || - g_file_has_uri_scheme (directory->details->location, "dns-sd"); + info = g_file_query_filesystem_info (directory->details->location, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, + NULL, NULL); + if (info) { + const gchar *type; + + type = g_file_info_get_attribute_string (info, "filesystem::type"); + is_remote = g_strv_contains (remote_types, type); + + g_object_unref (info); + } else { + is_remote = FALSE; + } + + return is_remote; } gboolean diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h index 5f6c0cdd8..34baa8684 100644 --- a/libnautilus-private/nautilus-directory.h +++ b/libnautilus-private/nautilus-directory.h @@ -213,7 +213,7 @@ gboolean nautilus_directory_is_local (NautilusDirector gboolean nautilus_directory_is_in_trash (NautilusDirectory *directory); gboolean nautilus_directory_is_in_recent (NautilusDirectory *directory); -gboolean nautilus_directory_is_in_network (NautilusDirectory *directory); +gboolean nautilus_directory_is_remote (NautilusDirectory *directory); /* Return false if directory contains anything besides a Nautilus metafile. * Only valid if directory is monitored. Used by the Trash monitor. diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index a7c0e609f..1d36b088a 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -6999,7 +6999,7 @@ nautilus_file_is_in_recent (NautilusFile *file) } /** - * nautilus_file_is_in_network + * nautilus_file_is_remote * * Check if this file is a file in Network. * @file: NautilusFile representing the file in question. @@ -7008,11 +7008,11 @@ nautilus_file_is_in_recent (NautilusFile *file) * **/ gboolean -nautilus_file_is_in_network (NautilusFile *file) +nautilus_file_is_remote (NautilusFile *file) { g_assert (NAUTILUS_IS_FILE (file)); - return nautilus_directory_is_in_network (file->details->directory); + return nautilus_directory_is_remote (file->details->directory); } /** diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index edb065b70..fb0f9311d 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -190,7 +190,7 @@ gboolean nautilus_file_is_archive (NautilusFile *file); gboolean nautilus_file_is_in_search (NautilusFile *file); gboolean nautilus_file_is_in_trash (NautilusFile *file); gboolean nautilus_file_is_in_recent (NautilusFile *file); -gboolean nautilus_file_is_in_network (NautilusFile *file); +gboolean nautilus_file_is_remote (NautilusFile *file); gboolean nautilus_file_is_other_locations (NautilusFile *file); gboolean nautilus_file_is_home (NautilusFile *file); gboolean nautilus_file_is_desktop_directory (NautilusFile *file); diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c index 68d7f2c7c..d50c418ec 100644 --- a/libnautilus-private/nautilus-search-directory.c +++ b/libnautilus-private/nautilus-search-directory.c @@ -157,6 +157,7 @@ start_search (NautilusSearchDirectory *search) { NautilusSearchEngineModel *model_provider; NautilusSearchEngineSimple *simple_provider; + NautilusFile *directory_as_file; gboolean recursive; if (!search->details->query) { @@ -183,7 +184,12 @@ start_search (NautilusSearchDirectory *search) nautilus_search_engine_model_set_model (model_provider, search->details->base_model); simple_provider = nautilus_search_engine_get_simple_provider (search->details->engine); - recursive = g_settings_get_boolean (nautilus_preferences, "enable-recursive-search"); + directory_as_file = nautilus_directory_get_corresponding_file (search->details->base_model); + /* It's too slow to search recursively on locations that are on the network. So + * for that case, just search in the current directory */ + recursive = g_settings_get_boolean (nautilus_preferences, "enable-recursive-search") && + !nautilus_file_is_remote (directory_as_file); + g_object_unref (directory_as_file); g_object_set (simple_provider, "recursive", recursive, NULL); reset_file_list (search); diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 121b9ff26..ef8a53ae9 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -709,13 +709,13 @@ showing_trash_directory (NautilusFilesView *view) } static gboolean -showing_network_directory (NautilusFilesView *view) +showing_remote_directory (NautilusFilesView *view) { NautilusFile *file; file = nautilus_files_view_get_directory_as_file (view); if (file != NULL) { - return nautilus_file_is_in_network (file); + return nautilus_file_is_remote (file); } return FALSE; } @@ -6121,7 +6121,7 @@ real_update_actions_state (NautilusFilesView *view) can_paste_files_into = (!selection_contains_recent && selection_count == 1 && can_paste_into_file (NAUTILUS_FILE (selection->data))); - show_properties = !showing_network_directory (view) && + show_properties = !showing_remote_directory (view) && (!NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view) || selection_count > 0); /* Right click actions */ |