[gvfs/wip/rishi/goa: 6/8] Better escaping / lookaside cache
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/rishi/goa: 6/8] Better escaping / lookaside cache
- Date: Mon, 31 Aug 2015 19:02:50 +0000 (UTC)
commit c5349e2d4483b09b6bb787f93d5da7621de119b3
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Aug 25 21:16:22 2015 +0200
Better escaping / lookaside cache
daemon/gvfsbackendgoogle.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 2604f6f..a5ca53e 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -86,6 +86,72 @@ G_DEFINE_TYPE(GVfsBackendGoogle, g_vfs_backend_google, G_VFS_TYPE_BACKEND)
/* ---------------------------------------------------------------------------------------------------- */
+static void
+insert_lookaside (GVfsBackendGoogle *self,
+ const gchar *parent_id,
+ const gchar *basename,
+ const gchar *id)
+{
+ gchar *key;
+
+ key = g_build_filename (parent_id, basename, NULL);
+ g_hash_table_insert (self->lookaside, g_strdup (key), g_strdup (id));
+ g_free (key);
+}
+
+static const gchar *
+lookup_lookaside (GVfsBackendGoogle *self,
+ const gchar *parent_id,
+ const gchar *basename)
+{
+ const gchar *id;
+ gchar *key;
+
+ key = g_build_filename (parent_id, basename, NULL);
+ id = g_hash_table_lookup (self->lookaside, key);
+ g_free (key);
+ return id;
+}
+
+static gchar *
+resolve_filename (GVfsBackendGoogle *self,
+ const gchar *filename)
+{
+ const gchar *id;
+ gchar *basename = NULL;
+ gchar *parent_id = NULL;
+ gchar *parent_path = NULL;
+ gchar *resolved_parent_path = NULL;
+ gchar *ret_val = NULL;
+
+ if (g_strcmp0 (filename, "/") == 0)
+ {
+ ret_val = g_strdup ("/");
+ goto out;
+ }
+
+ parent_path = g_path_get_dirname (filename);
+ resolved_parent_path = resolve_filename (self, parent_path);
+ if (resolved_parent_path == NULL)
+ goto out;
+
+ parent_id = g_path_get_basename (resolved_parent_path);
+ basename = g_path_get_basename (filename);
+ id = lookup_lookaside (self, parent_id, basename);
+ if (id == NULL)
+ goto out;
+
+ ret_val = g_build_filename (resolved_parent_path, id, NULL);
+
+ out:
+ g_free (parent_id);
+ g_free (parent_path);
+ g_free (resolved_parent_path);
+ return ret_val;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
static gchar *
escape_id (const gchar *id)
{
@@ -779,6 +845,7 @@ create_document (GVfsBackendGoogle *self,
if (is_root)
{
parent = GDATA_DOCUMENTS_FOLDER (self->root);
+ //parent_id = g_strdup (gdata_entry_get_id (GDATA_ENTRY (parent)));
}
else
{
@@ -822,6 +889,7 @@ create_document (GVfsBackendGoogle *self,
{
g_debug (" insert lookaside: %s -> %s\n", filename, path);
g_hash_table_insert (self->lookaside, g_strdup (filename), g_strdup (path));
+ //insert_lookaside (self, parent_id, title, id);
g_hash_table_foreach (self->monitors, emit_create_event, (gpointer) path);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]