[nautilus] file-undo-operations: change trashed files matching condition
- From: Răzvan-Mihai Chițu <razvanchitu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] file-undo-operations: change trashed files matching condition
- Date: Wed, 10 Feb 2016 11:52:40 +0000 (UTC)
commit d1fdc58be0731578572d17fb9c2992b22fab9bbb
Author: Razvan Chitu <razvan ch95 gmail com>
Date: Wed Feb 10 12:53:28 2016 +0200
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
.../nautilus-file-undo-operations.c | 10 +++++++++-
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 7201ced..47b9698 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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]