[nautilus/wip/rishi/gfile-google: 2/2] file-operations: Let directory copy / move work on Google Drive



commit a220d70b0e5f16193cf6bfa63b4983b240429ccd
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Sep 7 17:24:32 2015 +0200

    file-operations: Let directory copy / move work on Google Drive
    
    Immediately check if the newly created directory is volatile or not,
    and if it is then switch to using the "real" persistent URI.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751481

 libnautilus-private/nautilus-file-operations.c |   38 +++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 56c51ca..e411ba4 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -3729,6 +3729,7 @@ create_dest_dir (CommonJob *job,
        char *primary, *secondary, *details;
        int response;
        gboolean handled_invalid_filename;
+       gboolean res;
 
        handled_invalid_filename = *dest_fs_type != NULL;
 
@@ -3737,7 +3738,42 @@ create_dest_dir (CommonJob *job,
           copying the attributes, because we need to be sure we can write to it */
        
        error = NULL;
-       if (!g_file_make_directory (*dest, job->cancellable, &error)) {
+       res = g_file_make_directory (*dest, job->cancellable, &error);
+
+#ifdef G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE
+       if (res) {
+               GFileInfo *info = NULL;
+
+               info = g_file_query_info (*dest,
+                                         G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK","
+                                         G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE","
+                                         G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+                                         G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                         job->cancellable,
+                                         &error);
+               if (info == NULL) {
+                       res = FALSE;
+               } else {
+                       gboolean is_volatile;
+
+                       is_volatile = g_file_info_get_attribute_boolean (info,
+                                                                        
G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE);
+                       if (is_volatile) {
+                               GFile *real_dest;
+                               const gchar *target;
+
+                               target = g_file_info_get_symlink_target (info);
+                               real_dest = g_file_resolve_relative_path (*dest, target);
+                               g_object_unref (*dest);
+                               *dest = real_dest;
+                       }
+               }
+
+               g_clear_object (&info);
+       }
+#endif /* G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE */
+
+       if (!res) {
                if (IS_IO_ERROR (error, CANCELLED)) {
                        g_error_free (error);
                        return CREATE_DEST_DIR_FAILED;


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