GNOME Bugzilla – Bug 721981
Copy files from trash doesn't work correctly
Last modified: 2017-08-29 10:21:00 UTC
If I copy file (Ctrl+C) using Nautilus from trash and paste (Ctrl+V) somewhere, the file is copied wrongly to its original location... However when I drag and drop the file, it works correctly. Also gvfs-copy trash:///file path works correctly. Not sure whether it isn't Nautilus bug...
Looks like Nautilus bug, because GVfs get wrong path to pull. I think the bug is in nautilus-file-operations.c in function get_target_file_with_custom_name: /* if file is being restored from trash make sure it uses its original name */ if (g_file_has_uri_scheme (src, "trash")) { copyname = g_strdup (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH)); } The destination path is there replaced by the original path...
I've made some further investigation: - copy and past There is the problem I mentioned earlier. It can be fixed with following patch, set original basement to the file... - drag and drop This works, but it isn't use original basename. It uses basename from the trash dir, because src uri is file:// (not Trash://). But I think both operations should be equally, therefor drag and drop should be fixed to use correct uri.
Created attachment 287335 [details] [review] file-operations: fix copying from the trash Use original basename (not path) when creating target path.
The problem with drag and drop is that activation uri is used. It could be fixed by: diff --git a/libnautilus-private/nautilus-canvas-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c index 3fd46e7..b1a1928 100644 --- a/libnautilus-private/nautilus-canvas-dnd.c +++ b/libnautilus-private/nautilus-canvas-dnd.c @@ -236,7 +236,7 @@ icon_get_data_binder (NautilusCanvasIcon *icon, gpointer data) canvas_rect_world_to_widget (EEL_CANVAS (container), &world_rect, &widget_rect); uri = nautilus_canvas_container_get_icon_uri (container, icon); - if (!eel_uri_is_desktop (uri)) { + if (!eel_uri_is_desktop (uri) && !eel_uri_is_trash (uri)) { g_free (uri); uri = nautilus_canvas_container_get_icon_activation_uri (container, icon); } but it breaks e.g. opening trash files in non-gnome applications using drag and drop.
Review of attachment 287335 [details] [review]: Thanks Ondrej for the patch,this one LGTM
(In reply to Ondrej Holy from comment #4) > The problem with drag and drop is that activation uri is used. > > It could be fixed by: > > diff --git a/libnautilus-private/nautilus-canvas-dnd.c > b/libnautilus-private/nautilus-canvas-dnd.c > index 3fd46e7..b1a1928 100644 > --- a/libnautilus-private/nautilus-canvas-dnd.c > +++ b/libnautilus-private/nautilus-canvas-dnd.c > @@ -236,7 +236,7 @@ icon_get_data_binder (NautilusCanvasIcon *icon, gpointer > data) > canvas_rect_world_to_widget (EEL_CANVAS (container), &world_rect, > &widget_rect); > > uri = nautilus_canvas_container_get_icon_uri (container, icon); > - if (!eel_uri_is_desktop (uri)) { > + if (!eel_uri_is_desktop (uri) && !eel_uri_is_trash (uri)) { > g_free (uri); > uri = nautilus_canvas_container_get_icon_activation_uri > (container, icon); > } > > but it breaks e.g. opening trash files in non-gnome applications using drag > and drop. I think this is some trade-off we can assume. Mind doing a patch?
Attachment 287335 [details] pushed as 0d0d95d - file-operations: fix copying from the trash
*** Bug 765568 has been marked as a duplicate of this bug. ***