summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRazvan Chitu <razvan.ch95@gmail.com>2016-02-10 12:53:28 +0200
committerRazvan Chitu <razvan.ch95@gmail.com>2016-02-10 13:51:33 +0200
commitd1fdc58be0731578572d17fb9c2992b22fab9bbb (patch)
tree1890b0a162922d6d0b12d1a87ecbae7ed31cfe54
parent0b442e558384bb779931e62a97c6f9125759cfc0 (diff)
downloadnautilus-d1fdc58be0731578572d17fb9c2992b22fab9bbb.tar.gz
file-undo-operations: change trashed files matching condition
In Nautilus, undoing trash operations relies on the original path of deleted files and their deletion time. This time value is obtained after the operation is performed, which can lead to a mismatch. This mismatch would cause deleted files to not be restored by an undo operation, as they would not be recognised as being the originals. Compare the deletion time from the file in trash with the value stored in the undo information. If the difference is less or equal than an epsilon value, consider the files as matching. https://bugzilla.gnome.org/show_bug.cgi?id=761819
-rw-r--r--libnautilus-private/nautilus-file-undo-operations.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libnautilus-private/nautilus-file-undo-operations.c b/libnautilus-private/nautilus-file-undo-operations.c
index 7201ceda5..47b9698d4 100644
--- a/libnautilus-private/nautilus-file-undo-operations.c
+++ b/libnautilus-private/nautilus-file-undo-operations.c
@@ -33,6 +33,14 @@
#include "nautilus-file.h"
#include "nautilus-file-undo-manager.h"
+/* Since we use g_get_current_time for setting "orig_trash_time" in the undo
+ * info, there are situations where the difference between this value and the
+ * real deletion time can differ enough to make the rounding a difference of 1
+ * second, failing the equality check. To make sure we avoid this, and to be
+ * preventive, use 2 seconds epsilon.
+ */
+#define TRASH_TIME_EPSILON 2
+
G_DEFINE_TYPE (NautilusFileUndoInfo, nautilus_file_undo_info, G_TYPE_OBJECT)
enum {
@@ -1134,7 +1142,7 @@ trash_retrieve_files_to_restore_thread (GSimpleAsyncResult *res,
g_date_time_unref (date);
}
- if (trash_time == orig_trash_time) {
+ if (abs (orig_trash_time - trash_time) <= TRASH_TIME_EPSILON) {
/* File in the trash */
item = g_file_get_child (trash, g_file_info_get_name (info));
g_hash_table_insert (to_restore, item, g_object_ref (origfile));