Commit d1fdc58b authored by Razvan Chitu's avatar Razvan Chitu

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
parent 0b442e55
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment