[nautilus] file: Also use FS remote attribute in is_remote



commit 99f55748ef69a68df86b9a039998ee576d59b898
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Jun 7 19:55:45 2018 +0200

    file: Also use FS remote attribute in is_remote
    
    Gio can provide us this info, so we can use this together with the checks
    nautilus already does.
    
    However, since there are many false-positives cases (like when using a fuse
    filesystem that is actually a remote mount, like sshfs or similar), we can't
    take this information as granted.

 src/nautilus-directory-async.c |  4 +++-
 src/nautilus-file-private.h    |  3 ++-
 src/nautilus-file.c            | 28 ++++++++++++++++++++++++++++
 src/nautilus-file.h            |  2 ++
 4 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-directory-async.c b/src/nautilus-directory-async.c
index e18ca4026..1b930f6a4 100644
--- a/src/nautilus-directory-async.c
+++ b/src/nautilus-directory-async.c
@@ -4009,6 +4009,7 @@ got_filesystem_info (FilesystemInfoState *state,
         file->details->filesystem_readonly =
             g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
         filesystem_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
+        file->details->filesystem_remote = g_file_info_get_attribute_boolean (info, 
G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
         if (g_strcmp0 (eel_ref_str_peek (file->details->filesystem_type), filesystem_type) != 0)
         {
             eel_ref_str_unref (file->details->filesystem_type);
@@ -4091,7 +4092,8 @@ filesystem_info_start (NautilusDirectory *directory,
     g_file_query_filesystem_info_async (location,
                                         G_FILE_ATTRIBUTE_FILESYSTEM_READONLY ","
                                         G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW ","
-                                        G_FILE_ATTRIBUTE_FILESYSTEM_TYPE,
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_TYPE ","
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE,
                                         G_PRIORITY_DEFAULT,
                                         state->cancellable,
                                         query_filesystem_info_callback,
diff --git a/src/nautilus-file-private.h b/src/nautilus-file-private.h
index 321ff9ac5..3ed301a75 100644
--- a/src/nautilus-file-private.h
+++ b/src/nautilus-file-private.h
@@ -194,7 +194,8 @@ struct NautilusFileDetails
        eel_boolean_bit filesystem_readonly           : 1;
        eel_boolean_bit filesystem_use_preview        : 2; /* GFilesystemPreviewType */
        eel_boolean_bit filesystem_info_is_up_to_date : 1;
-        eel_ref_str     filesystem_type;
+       eel_boolean_bit filesystem_remote             : 1;
+       eel_ref_str     filesystem_type;
 
        time_t trash_time; /* 0 is unknown */
        time_t recency; /* 0 is unknown */
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index e58fb092a..dc3a788d0 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -4688,6 +4688,29 @@ nautilus_file_get_filesystem_type (NautilusFile *file)
     return filesystem_type;
 }
 
+gboolean
+nautilus_file_get_filesystem_remote (NautilusFile *file)
+{
+    NautilusFile *parent;
+
+    g_assert (NAUTILUS_IS_FILE (file));
+
+    if (nautilus_file_is_directory (file))
+    {
+        return file->details->filesystem_remote;
+    }
+    else
+    {
+        parent = nautilus_file_get_parent (file);
+        if (parent != NULL)
+        {
+            return parent->details->filesystem_remote;
+        }
+    }
+
+    return FALSE;
+}
+
 gboolean
 nautilus_file_should_show_thumbnail (NautilusFile *file)
 {
@@ -8070,6 +8093,11 @@ nautilus_file_is_remote (NautilusFile *file)
 
     g_assert (NAUTILUS_IS_FILE (file));
 
+    if (nautilus_file_get_filesystem_remote (file))
+    {
+        return TRUE;
+    }
+
     filesystem_type = nautilus_file_get_filesystem_type (file);
 
     return filesystem_type != NULL && g_strv_contains (remote_types, filesystem_type);
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 0eb5b3a96..8fce62505 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -248,6 +248,8 @@ char *                  nautilus_file_get_filesystem_id                 (Nautilu
 
 char *                  nautilus_file_get_filesystem_type               (NautilusFile                   
*file);
 
+gboolean                nautilus_file_get_filesystem_remote             (NautilusFile                   
*file);
+
 NautilusFile *          nautilus_file_get_trash_original_file           (NautilusFile                   
*file);
 
 /* Permissions. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]