Commit 62ba6d83 authored by Ernestas Kulik's avatar Ernestas Kulik 🦑

search-engine: Query file system to determine remoteness

Querying the file cache in is_recursive_search() does not guarantee that
the file system field will be populated with a value, and somehow
results in data races, in turn resulting in random crashes/file list
corruption.

Hopefully fixes #640,
closes #632 and resolves
#602
parent d3b4555b
Pipeline #32385 passed with stage
in 2 minutes and 50 seconds
......@@ -1489,3 +1489,21 @@ location_settings_search_get_recursive_for_location (GFile *location)
return recursive;
}
gboolean
nautilus_file_system_is_remote (const char *file_system)
{
static const gchar * const remote_types[] =
{
"afp",
"google-drive",
"sftp",
"webdav",
"ftp",
"nfs",
"cifs",
NULL
};
return file_system != NULL && g_strv_contains (remote_types, file_system);
}
......@@ -141,3 +141,5 @@ gchar * nautilus_uri_to_native_uri (const gchar *uri);
NautilusQueryRecursive location_settings_search_get_recursive (void);
NautilusQueryRecursive location_settings_search_get_recursive_for_location (GFile *location);
gboolean nautilus_file_system_is_remote (const char *file_system);
......@@ -8065,18 +8065,6 @@ nautilus_file_is_in_starred (NautilusFile *file)
return nautilus_directory_is_in_starred (file->details->directory);
}
static const gchar * const remote_types[] =
{
"afp",
"google-drive",
"sftp",
"webdav",
"ftp",
"nfs",
"cifs",
NULL
};
/**
* nautilus_file_is_remote
*
......@@ -8100,7 +8088,7 @@ nautilus_file_is_remote (NautilusFile *file)
filesystem_type = nautilus_file_get_filesystem_type (file);
return filesystem_type != NULL && g_strv_contains (remote_types, filesystem_type);
return nautilus_file_system_is_remote (filesystem_type);
}
/**
......
......@@ -23,7 +23,7 @@
#include "nautilus-search-engine.h"
#include "nautilus-search-engine-private.h"
#include "nautilus-file.h"
#include "nautilus-file-utilities.h"
#include "nautilus-search-engine-model.h"
#include <glib/gi18n.h>
#define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH
......@@ -563,8 +563,20 @@ is_recursive_search (NautilusSearchEngineType engine_type,
case NAUTILUS_QUERY_RECURSIVE_LOCAL_ONLY:
{
g_autoptr (NautilusFile) file = nautilus_file_get (location);
return !nautilus_file_is_remote (file);
g_autoptr (GFileInfo) file_system_info = NULL;
file_system_info = g_file_query_filesystem_info (location,
G_FILE_ATTRIBUTE_FILESYSTEM_TYPE,
NULL, NULL);
if (file_system_info != NULL)
{
const char *file_system;
file_system = g_file_info_get_attribute_string (file_system_info,
G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
return !nautilus_file_system_is_remote (file_system);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment