[gvfs/wip/oholy/do-not-use-desktop-files: 6/6] google: Do not create .desktop files for native files



commit 5bc9cb7802b7e9e797ff73a53a04f41a8cf7682a
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Jun 5 13:04:15 2018 +0200

    google: Do not create .desktop files for native files
    
    Currently, .desktop file with a link to the original location is provided,
    when a native file is opened because Google doesn't provide its proprietary
    formats and GLocalFile doesn't know G_FILE_TYPE_SHORTCUT. It is a bit
    tricky and confusing, among other because the .desktop files aren't
    automatically converted back to native files when writing.
    
    What is worse, Nautilus has dropped support for .desktop files recently,
    so you see "There was an error launching the application." instead of the
    requested file. It doesn't make more sense to provide this .desktop files,
    so let's remove this fallback and return error instead.
    
    https://gitlab.gnome.org/GNOME/nautilus/issues/448

 daemon/gvfsbackendgoogle.c | 68 +++++++++-------------------------------------
 1 file changed, 13 insertions(+), 55 deletions(-)
---
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 23bd8f58..7bea4bff 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -907,7 +907,6 @@ build_file_info (GVfsBackendGoogle      *self,
   gchar *escaped_name = NULL;
   gchar *content_type = NULL;
   gchar *copy_name = NULL;
-  gchar *generated_copy_name = NULL;
   gint64 atime;
   gint64 ctime;
   gint64 mtime;
@@ -1025,21 +1024,7 @@ build_file_info (GVfsBackendGoogle      *self,
   g_file_info_set_display_name (info, title);
   g_file_info_set_edit_name (info, title);
 
-  generated_copy_name = generate_copy_name (self, entry);
-
-  /* While copying remote Drive content to local storage, we want to
-   * create Link-type desktop files because GLocalFile doesn't know
-   * about shortcuts. That might change in future.
-   */
-  if (file_type == G_FILE_TYPE_SHORTCUT)
-    {
-      copy_name = g_strconcat (generated_copy_name, ".desktop", NULL);
-    }
-  else
-    {
-      copy_name = generated_copy_name;
-      generated_copy_name = NULL;
-    }
+  copy_name = generate_copy_name (self, entry);
 
   /* Sanitize copy-name by replacing slashes with dashes. This is
    * what nautilus does (for desktop files).
@@ -1097,7 +1082,6 @@ build_file_info (GVfsBackendGoogle      *self,
 
  out:
   g_free (copy_name);
-  g_free (generated_copy_name);
   g_free (escaped_name);
   g_free (content_type);
   g_list_free (links);
@@ -2249,6 +2233,8 @@ g_vfs_backend_google_open_for_read (GVfsBackend        *_self,
   GError *error;
   gchar *content_type = NULL;
   gchar *entry_path = NULL;
+  GDataAuthorizationDomain *auth_domain;
+  const gchar *uri;
 
   g_rec_mutex_lock (&self->mutex);
   g_debug ("+ open_for_read: %s\n", filename);
@@ -2278,47 +2264,19 @@ g_vfs_backend_google_open_for_read (GVfsBackend        *_self,
       goto out;
     }
 
-  /* While copying remote Drive content to local storage, we want to
-   * create Link-type desktop files because GLocalFile doesn't know
-   * about shortcuts. That might change in future.
-   */
-  if (g_str_has_prefix (content_type, CONTENT_TYPE_PREFIX_GOOGLE))
+  if (is_native_file (entry))
     {
-      GDataLink *alternate;
-      GKeyFile *file;
-      const gchar *title;
-      const gchar *uri;
-      gchar *data;
-      gsize length;
-
-      file = g_key_file_new ();
-
-      title = gdata_entry_get_title (entry);
-      g_key_file_set_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, title);
-      g_key_file_set_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TYPE, "Link");
-
-      alternate = gdata_entry_look_up_link (entry, GDATA_LINK_ALTERNATE);
-      uri = gdata_link_get_uri (alternate);
-      g_key_file_set_string (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_URL, uri);
-
-      data = g_key_file_to_data (file, &length, NULL);
-      stream = g_memory_input_stream_new_from_data (data, (gssize) length, g_free);
-
-      g_key_file_free (file);
+      g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE, _("File is not a regular 
file"));
+      goto out;
     }
-  else
-    {
-      GDataAuthorizationDomain *auth_domain;
-      const gchar *uri;
 
-      auth_domain = gdata_documents_service_get_primary_authorization_domain ();
-      uri = gdata_entry_get_content_uri (entry);
-      stream = gdata_download_stream_new (GDATA_SERVICE (self->service), auth_domain, uri, cancellable);
-      if (stream == NULL)
-        {
-          g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_FAILED, _("Error getting data from 
file"));
-          goto out;
-        }
+  auth_domain = gdata_documents_service_get_primary_authorization_domain ();
+  uri = gdata_entry_get_content_uri (entry);
+  stream = gdata_download_stream_new (GDATA_SERVICE (self->service), auth_domain, uri, cancellable);
+  if (stream == NULL)
+    {
+      g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_FAILED, _("Error getting data from file"));
+      goto out;
     }
 
   g_object_set_data_full (G_OBJECT (stream), "g-vfs-backend-google-entry", g_object_ref (entry), 
g_object_unref);


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