Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trashing symlink of file/folder deletes the original file/folder #412

Closed
v4i1n1a9y8 opened this issue Nov 25, 2019 · 4 comments
Closed

Trashing symlink of file/folder deletes the original file/folder #412

v4i1n1a9y8 opened this issue Nov 25, 2019 · 4 comments

Comments

@v4i1n1a9y8
Copy link

Linux distribution and version

Fedora 31

Flatpak version

Flatpak 1.4.3

Description of the problem

So i tried creating a flatpak build of https://github.com/spheras/desktopfolder .Everything builds and runs fine except if i use "Move to trash" option to a linked(symlinked) file/folder, it trashes the original file instead of the symlink.
I tried manually building it without flatpak and the "Move to trash" works as expected, it removes the symlink rather than the original file. So the bug might not be from the app.

Steps to reproduce

  1. Build the flatpak and run
  2. Minimize everything and right click on the desktop
  3. Click "New" -> "Link to File" and select a file from different location
  4. Right click this file (the file previously linked on the desktop) and choose "Move to Trash"
  5. The original file will be trashed instead of the symlink.

Build file:

{
    "app-id": "com.github.spheras.desktopfolder",
    "runtime": "org.gnome.Platform",
    "runtime-version": "3.34",
    "sdk": "org.gnome.Sdk",
    "command": "com.github.spheras.desktopfolder",
    "finish-args": [
        "--share=network",
        "--share=ipc",
        "--socket=fallback-x11",
        "--socket=wayland",
        "--filesystem=xdg-run/dconf",
        "--filesystem=~/.config/dconf:ro",
        "--talk-name=ca.desrt.dconf",
        "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
    ],
    "cleanup": [
        "/include",
        "/lib/pkgconfig",
        "/man",
        "/share/doc",
        "/share/gtk-doc",
        "/share/man",
        "/share/pkgconfig",
        "/share/vala",
        "*.la",
        "*.a"
    ],
    "modules": [
        {
            "name" : "gtksourceview",
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "git",
                    "url" : "https://gitlab.gnome.org/GNOME/gtksourceview.git"
                }
            ]
        },
         {
            "name" : "libwnck-3.0",
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/GNOME/libwnck/archive/3.32.0.tar.gz",
                    "sha256" : "fa70bbebfc29105ebdfcc13e78b0ea0f3c8019c0c499c2dbd5ff8a661c0b6e82"
                }
            ],
            "modules": [
                {
                    "name": "gettext",
                    "sources": [{
                        "type": "archive",
                        "url": "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.tar.gz",
                        "sha256": "3da4f6bd79685648ecf46dab51d66fcdddc156f41ed07e580a696a38ac61d48f"
                    }]
                }
            ]

        },
        {
        	"name": "intltool",
                "sources": [{
                        "type": "archive",
                        "url": "https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz",
                        "sha256": "67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd"
                    }]
	},
        {
            "name" : "desktopfolder",
            "buildsystem" : "meson",
            "config-opts" : [
            ],
            "sources" : [
                {
                    "type" : "git",
                    "url" : "https://github.com/spheras/desktopfolder.git"
                },
                {
                    "type" : "patch",
                    "path" : "data.patch"
                }
            ]
        }
    ]
}

data.patch

diff --git a/data/meson.build b/data/meson.build
index a97e7f5..093e5d6 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -48,7 +48,7 @@ i18n.merge_file (
     input: desktop_exe,
     output: meson.project_name() + '-autostart.desktop',
     install: true,
-    install_dir: 'etc/xdg/autostart',
+    install_dir: 'app/etc/xdg/autostart',
     po_dir: join_paths(meson.source_root (), 'po'),
     type: 'desktop'
 )
diff --git a/meson.build b/meson.build
index be177be..edd16bb 100644
--- a/meson.build
+++ b/meson.build
@@ -92,7 +92,7 @@ executable(
         dependency('json-glib-1.0'),
         dependency('gdk-pixbuf-2.0'),
         dependency('libwnck-3.0'),
-        dependency('gtksourceview-3.0'),
+        dependency('gtksourceview-4'),
         m_dep
     ],
     install : true

@alexlarsson
Copy link
Member

This is a bug in the trash file portal. Can you file a bug in https://github.com/flatpak/xdg-desktop-portal/

@matthiasclasen
Copy link
Contributor

Lets just transfer this one

@matthiasclasen matthiasclasen transferred this issue from flatpak/flatpak Nov 27, 2019
@matthiasclasen
Copy link
Contributor

On the portal side, we just do this:

path = xdp_app_info_get_path_for_fd (app_info, fd, 0, NULL, &writable);
file = g_file_new_for_path (path);
g_file_trash (file, NULL, NULL);

And the glib side does:

path = g_file_get_path (file);
fd = g_open (path, O_RDWR | O_CLOEXEC);

I guess the latter needs an O_NOFOLLOW thrown in ?

gnomesysadmins pushed a commit to GNOME/glib that referenced this issue Dec 10, 2019
We got a complaint here that trashing via the
portal deletes the target of a symlink, not the
symlink itself. It turns out that following the
symlink already happens on the glib side.

flatpak/xdg-desktop-portal#412
gnomesysadmins pushed a commit to GNOME/glib that referenced this issue Dec 11, 2019
We got a complaint here that trashing via the
portal deletes the target of a symlink, not the
symlink itself. It turns out that following the
symlink already happens on the glib side.

flatpak/xdg-desktop-portal#412
@matthiasclasen
Copy link
Contributor

fixed in glib

agx pushed a commit to agx/xdg-desktop-portal that referenced this issue Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants