After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 721981 - Copy files from trash doesn't work correctly
Copy files from trash doesn't work correctly
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Trash
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
: 765568 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-01-11 09:46 UTC by Ondrej Holy
Modified: 2017-08-29 10:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
file-operations: fix copying from the trash (1.12 KB, patch)
2014-09-29 11:12 UTC, Ondrej Holy
committed Details | Review

Description Ondrej Holy 2014-01-11 09:46:44 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...
Comment 1 Ondrej Holy 2014-02-19 15:31:00 UTC
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...
Comment 2 Ondrej Holy 2014-09-29 11:10:37 UTC
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.
Comment 3 Ondrej Holy 2014-09-29 11:12:39 UTC
Created attachment 287335 [details] [review]
file-operations: fix copying from the trash

Use original basename (not path) when creating target path.
Comment 4 Ondrej Holy 2014-09-30 12:24:21 UTC
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.
Comment 5 Carlos Soriano 2016-03-02 10:54:08 UTC
Review of attachment 287335 [details] [review]:

Thanks Ondrej for the patch,this one LGTM
Comment 6 Carlos Soriano 2016-03-02 10:59:13 UTC
(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?
Comment 7 Carlos Soriano 2016-03-07 20:10:24 UTC
Attachment 287335 [details] pushed as 0d0d95d - file-operations: fix copying from the trash
Comment 8 António Fernandes 2017-08-29 10:21:00 UTC
*** Bug 765568 has been marked as a duplicate of this bug. ***