summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-08-01 16:17:42 +0200
committerOndrej Holy <oholy@redhat.com>2018-08-16 18:57:53 +0200
commit06bad3ebbe61d114a068cb6a45bed27c00b13ef9 (patch)
tree8c04d5fa5a2a24ae96a07b89177feaf6f82adaa2
parent7c830d02efbe8aa85ba794221b6dd518a90bb214 (diff)
downloadgvfs-wip/oholy/google-cache-conservative.tar.gz
google: Handle child of volatile also as volatilewip/oholy/google-cache-conservative
Files in volatile folder should be also marked as volatile. Volatile handling is a bit simplified as a part of this patch also.
-rw-r--r--daemon/gvfsbackendgoogle.c58
1 files changed, 19 insertions, 39 deletions
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 4eb8dbfe..3823cfe4 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);
@@ -1066,6 +1073,7 @@ build_file_info (GVfsBackendGoogle *self,
}
out:
+ g_free (symlink_name);
g_free (copy_name);
g_free (escaped_name);
g_free (content_type);
@@ -1435,10 +1443,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);
@@ -2012,9 +2022,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);
@@ -2028,16 +2036,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);
@@ -2049,7 +2051,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);
}
@@ -2067,10 +2068,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);
@@ -2078,13 +2077,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,
@@ -2092,8 +2085,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)
@@ -2106,7 +2098,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");
}
@@ -2122,18 +2113,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,
@@ -2141,8 +2123,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)
@@ -2155,7 +2136,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;
}