[gvfs] google: Mark files you can't see on the web as hidden



commit 3aade766e1793bbf3ba2ecd29aba44d0467a0c6d
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Oct 15 16:08:34 2015 +0200

    google: Mark files you can't see on the web as hidden
    
    Files without the parent are currently shown in google backend root.
    You can see many files consequently, which are not shown in your google
    drive folder on the web. Those files can be shared with you, or you
    opened them in some google applications (i.e. google docs). Mark those
    files as hidden to see same files as you can see on the web. Also mark
    the files as undeletable, because it is not possible to delete them
    from the obvious reason.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756644

 daemon/gvfsbackendgoogle.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 099be28..0acec9a 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -886,8 +886,10 @@ build_file_info (GVfsBackendGoogle      *self,
 {
   GFileType file_type;
   GList *authors;
+  GList *links;
   gboolean is_folder = FALSE;
   gboolean is_root = FALSE;
+  gboolean has_parent = FALSE;
   const gchar *etag;
   const gchar *id;
   const gchar *name;
@@ -907,7 +909,9 @@ build_file_info (GVfsBackendGoogle      *self,
   if (entry == self->root)
     is_root = TRUE;
 
-  g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, !is_root);
+  links = gdata_entry_look_up_links (entry, GDATA_LINK_PARENT);
+  has_parent = (links != NULL);
+
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME, !is_root);
 
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, is_folder);
@@ -916,6 +920,9 @@ build_file_info (GVfsBackendGoogle      *self,
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE, is_symlink);
 
   g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, FALSE);
+  g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, !is_root && has_parent);
+
+  g_file_info_set_is_hidden (info, !has_parent);
 
   if (is_folder)
     {
@@ -1079,6 +1086,7 @@ build_file_info (GVfsBackendGoogle      *self,
   g_free (generated_copy_name);
   g_free (escaped_name);
   g_free (content_type);
+  g_list_free (links);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */


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