[nautilus] undo: fix undo move to trash



commit c063418e66ed0fdc40b4fd48bc5bd29c0cbefa09
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Jan 21 18:07:35 2012 -0500

    undo: fix undo move to trash
    
    We were querying the mtime of the trashed file after it was already
    trashed, and we were also overflowing the guint64 assigning -1 to it.

 libnautilus-private/nautilus-file-operations.c |   27 ++++++++++++-----------
 1 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index e8a858a..1f355f0 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -1781,6 +1781,19 @@ trash_files (CommonJob *job, GList *files, int *files_skipped)
 		file = l->data;
 
 		error = NULL;
+		mtime = 0;
+
+		if (job->undo_info != NULL) {
+			info = g_file_query_info (file,
+						  G_FILE_ATTRIBUTE_TIME_MODIFIED,
+						  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, 
+						  NULL, NULL);
+
+			if (info != NULL) {
+				mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+				g_object_unref (info);
+			}
+		}
 
 		if (!g_file_trash (file, job->cancellable, &error)) {
 			if (job->skip_all_error) {
@@ -1829,19 +1842,7 @@ trash_files (CommonJob *job, GList *files, int *files_skipped)
 		} else {
 			nautilus_file_changes_queue_file_removed (file);
 
-			if (job->undo_info != NULL) {
-				info = g_file_query_info (file,
-							  G_FILE_ATTRIBUTE_TIME_MODIFIED,
-							  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, 
-							  NULL, NULL);
-
-				if (info != NULL) {
-					mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-					g_object_unref (info);
-				} else {
-					mtime = -1;
-				}
-
+			if (job->undo_info != NULL && mtime != 0) {
 				nautilus_file_undo_info_trash_add_file (NAUTILUS_FILE_UNDO_INFO_TRASH (job->undo_info),
 									file, mtime);
 			}



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