[gvfs/wip/oholy/google-cache-conservative: 39/39] google: Handle child of volatile also as volatile



commit 7a1c184608ff93e8344e0aa6d6b7bfa689c43a67
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Aug 1 16:17:42 2018 +0200

    google: Handle child of volatile also as volatile
    
    Files in volatile folder should be also marked as volatile.
    
    Volatile handling is a bit simplified as a part of this patch also.

 daemon/gvfsbackendgoogle.c | 58 +++++++++++++++-------------------------------
 1 file changed, 19 insertions(+), 39 deletions(-)
---
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 142acd5e..8c05699b 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -881,8 +881,7 @@ build_file_info (GVfsBackendGoogle      *self,
                  GFileQueryInfoFlags     flags,
                  GFileInfo              *info,
                  GFileAttributeMatcher  *matcher,
-                 gboolean                is_symlink,
-                 const gchar            *symlink_name,
+                 const gchar            *filename,
                  const gchar            *entry_path,
                  GError                **error)
 {
@@ -890,6 +889,7 @@ build_file_info (GVfsBackendGoogle      *self,
   GList *authors;
   gboolean is_folder = FALSE;
   gboolean is_root = FALSE;
+  gboolean is_symlink = FALSE;
   const gchar *etag;
   const gchar *id;
   const gchar *name;
@@ -897,6 +897,7 @@ build_file_info (GVfsBackendGoogle      *self,
   gchar *escaped_name = NULL;
   gchar *content_type = NULL;
   gchar *copy_name = NULL;
+  gchar *symlink_name = NULL;
   gint64 atime;
   gint64 ctime;
   gint64 mtime;
@@ -908,6 +909,12 @@ build_file_info (GVfsBackendGoogle      *self,
   if (entry == self->root)
     is_root = TRUE;
 
+  if (filename != NULL && g_strcmp0 (entry_path, filename) != 0) /* volatile */
+    {
+      is_symlink = TRUE;
+      symlink_name = g_path_get_basename (filename);
+    }
+
   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);
@@ -1058,6 +1065,7 @@ build_file_info (GVfsBackendGoogle      *self,
     }
 
  out:
+  g_free (symlink_name);
   g_free (copy_name);
   g_free (escaped_name);
   g_free (content_type);
@@ -1427,10 +1435,12 @@ g_vfs_backend_google_enumerate (GVfsBackend           *_self,
         {
           GFileInfo *info;
           gchar *entry_path;
+          gchar *child_filename;
 
           info = g_file_info_new ();
           entry_path = g_build_path ("/", parent_path, gdata_entry_get_id (GDATA_ENTRY (entry)), NULL);
-          build_file_info (self, entry, flags, info, matcher, FALSE, NULL, entry_path, NULL);
+          child_filename = g_build_filename (filename, gdata_entry_get_id (GDATA_ENTRY (entry)), NULL);
+          build_file_info (self, entry, flags, info, matcher, child_filename, entry_path, NULL);
           g_vfs_job_enumerate_add_info (job, info);
           g_object_unref (info);
           g_free (entry_path);
@@ -2004,9 +2014,7 @@ g_vfs_backend_google_query_info (GVfsBackend           *_self,
   GCancellable *cancellable = G_VFS_JOB (job)->cancellable;
   GDataEntry *entry;
   GError *error;
-  gboolean is_symlink = FALSE;
   gchar *entry_path = NULL;
-  gchar *symlink_name = NULL;
 
   g_rec_mutex_lock (&self->mutex);
   g_debug ("+ query_info: %s, %d\n", filename, flags);
@@ -2020,16 +2028,10 @@ g_vfs_backend_google_query_info (GVfsBackend           *_self,
       goto out;
     }
 
-  if (g_strcmp0 (entry_path, filename) != 0) /* volatile */
-    {
-      is_symlink = TRUE;
-      symlink_name = g_path_get_basename (filename);
-    }
-
-  g_debug ("  entry path: %s (%d)\n", entry_path, is_symlink);
+  g_debug ("  entry path: %s\n", entry_path);
 
   error = NULL;
-  build_file_info (self, entry, flags, info, matcher, is_symlink, symlink_name, entry_path, &error);
+  build_file_info (self, entry, flags, info, matcher, filename, entry_path, &error);
   if (error != NULL)
     {
       g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
@@ -2041,7 +2043,6 @@ g_vfs_backend_google_query_info (GVfsBackend           *_self,
 
  out:
   g_free (entry_path);
-  g_free (symlink_name);
   g_debug ("- query_info\n");
   g_rec_mutex_unlock (&self->mutex);
 }
@@ -2059,10 +2060,8 @@ g_vfs_backend_google_query_info_on_read (GVfsBackend           *_self,
   GDataEntry *entry;
   GError *error;
   GInputStream *stream = G_INPUT_STREAM (handle);
-  gboolean is_symlink = FALSE;
   const gchar *filename;
   gchar *entry_path = NULL;
-  gchar *symlink_name = NULL;
 
   g_debug ("+ query_info_on_read: %p\n", handle);
 
@@ -2070,13 +2069,7 @@ g_vfs_backend_google_query_info_on_read (GVfsBackend           *_self,
   filename = g_object_get_data (G_OBJECT (stream), "g-vfs-backend-google-filename");
   entry_path = g_object_get_data (G_OBJECT (stream), "g-vfs-backend-google-entry-path");
 
-  if (g_strcmp0 (entry_path, filename) != 0) /* volatile */
-    {
-      is_symlink = TRUE;
-      symlink_name = g_path_get_basename (filename);
-    }
-
-  g_debug ("  entry path: %s (%d)\n", entry_path, is_symlink);
+  g_debug ("  entry path: %s\n", entry_path);
 
   error = NULL;
   build_file_info (self,
@@ -2084,8 +2077,7 @@ g_vfs_backend_google_query_info_on_read (GVfsBackend           *_self,
                    G_FILE_QUERY_INFO_NONE,
                    info,
                    matcher,
-                   is_symlink,
-                   symlink_name,
+                   filename,
                    entry_path,
                    &error);
   if (error != NULL)
@@ -2098,7 +2090,6 @@ g_vfs_backend_google_query_info_on_read (GVfsBackend           *_self,
   g_vfs_job_succeeded (G_VFS_JOB (job));
 
  out:
-  g_free (symlink_name);
   g_debug ("- query_info_on_read\n");
 }
 
@@ -2114,18 +2105,9 @@ g_vfs_backend_google_query_info_on_write (GVfsBackend           *_self,
   GVfsBackendGoogle *self = G_VFS_BACKEND_GOOGLE (_self);
   GError *error;
   WriteHandle *wh = (WriteHandle *) handle;
-  gboolean is_symlink = FALSE;
-  gchar *symlink_name = NULL;
 
   g_debug ("+ query_info_on_write: %p\n", handle);
-
-  if (g_strcmp0 (wh->entry_path, wh->filename) != 0) /* volatile */
-    {
-      is_symlink = TRUE;
-      symlink_name = g_path_get_basename (wh->filename);
-    }
-
-  g_debug ("  entry path: %s (%d)\n", wh->entry_path, is_symlink);
+  g_debug ("  entry path: %s\n", wh->entry_path);
 
   error = NULL;
   build_file_info (self,
@@ -2133,8 +2115,7 @@ g_vfs_backend_google_query_info_on_write (GVfsBackend           *_self,
                    G_FILE_QUERY_INFO_NONE,
                    info,
                    matcher,
-                   is_symlink,
-                   symlink_name,
+                   wh->filename,
                    wh->entry_path,
                    &error);
   if (error != NULL)
@@ -2147,7 +2128,6 @@ g_vfs_backend_google_query_info_on_write (GVfsBackend           *_self,
   g_vfs_job_succeeded (G_VFS_JOB (job));
 
  out:
-  g_free (symlink_name);
   g_debug ("- query_info_on_write\n");
   return TRUE;
 }


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