Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-126621

moveToTrash fails to remove a symlink to a directory after trashing

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.7.3, 6.8.0 Beta2, 6.9.0 FF
    • 6.7
    • Core: I/O
    • None
    • ubuntu 22
    • Linux/Wayland
    • 3302b0cdc (dev), 591a9512a (6.8), 3a01c97d0 (6.7)

    Description

      My bash steps

      mkdir ~/myFolder
      ln -s ~/myFolder ~/mySymlink
      cd ~/mySymlink
      touch 1 2 3

      My Qt code

      qDebug() << QFile::moveToTrash("/home/user/mySymlink/");
      true
      

      And I open Trash and see mySymlink, looks good but /home/user/mySymlink/ also alive! So moveToTrash doesn't do move to trash action, it do copy to trash action. To make move to trash action I should do Qt code without symbol / at the and

      qDebug() << QFile::moveToTrash("/home/user/mySymlink");
      true
      

      Yes, in this case the mySymlink is really removed. It looks like not a bug but feature. If you think that this is feature then I suggest to describe this behavior in docs.

      P.S. For folder it is no matter does you use / at the end or not so QFile::moveToTrash("/home/user/myFolder/") is the same as QFile::moveToTrash("/home/user/myFolder");

      P.P.S. But if you use QFile::moveToTrash("/home/user/myFolder/../Folder2") then I expect big problem...

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              thiago Thiago Macieira
              dungeonlords Andrei Cherniaev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes