I just lost a fair amount of data (luckily non-critical) because dolphin in 5.x (I checked three recent versions) behaves in the following manner: 1. If a remote directory is not explored, it appears empty within the filesystem (displaying 0 items in the panel) 2. If you then use `rmdir *` in the terminal to clear empty directories, leaving those that have files, the remote mounted filesystem has the same structure, so rmdir dutifully removes all directories including all files. **Reproduction:** This can be reproduced via this on the remote system (via ssh or some other "hidden from dolphin" method): `mkdir -p $HOME/test/foo/bar ; echo MyData >$HOME/test/foo/bar/file.txt` Then go to $HOME/test using sftp: url in dolphin, open the terminal and type `rmdir foo` **Observed behavior:** All data and files are removed from the mounted filesystem. **Expected behavior:** rmdir should see files inside the directory and not remove the directory. --- I have not tested under KDE 6, but did test under a couple other 5.x Plasma desktops and observed the same behavior. [Administrivia note: I searched for this bug and the appropriate classification; I assume dolphin may be incorrect, but couldn't determine the correct classification. Please reclassify to the correct software!]
I'm assuming you're using the sftp:// url in dolphin while the terminal sees the kio-fuse mount, e.g. /run/user/1000/kio-fuse.... Can you post a screenshot of such a situation for clarity? > 1. If a remote directory is not explored, it appears empty within the filesystem (displaying 0 items in the panel) Do you mean the terminal panel or the dolphin panel? It's intentional that directories are not populated unless necessary to avoid potentially slow network requests. > 2. If you then use `rmdir *` in the terminal to clear empty directories, leaving those that have files, the remote mounted filesystem has the same structure, so rmdir dutifully removes all directories including all files. rmdir is supposed to fail on nonempty directories, so the question is which layer is wrong here. kio-fuse translates the rmdir call on directories to KIO::del, unless it already knows that it has items. KIO::del appears to do a recursive deletion by default, which is wrong in this context. For directories, KIO::rmdir is probably more appropriate.
A possibly relevant merge request was started @ https://invent.kde.org/system/kio-fuse/-/merge_requests/77
Data loss bugs are Critical; see https://community.kde.org/index.php?title=Guidelines_and_HOWTOs/Bug_triaging#Set_the_Severity_field Resetting severity.
(In reply to Fabian Vogt from comment #1) > I'm assuming you're using the sftp:// url in dolphin while the terminal sees > the kio-fuse mount, e.g. /run/user/1000/kio-fuse.... > Can you post a screenshot of such a situation for clarity? This is accurate. I will post a screenshot shortly. > > 1. If a remote directory is not explored, it appears empty within the filesystem (displaying 0 items in the panel) > > Do you mean the terminal panel or the dolphin panel? It's intentional that > directories are not populated unless necessary to avoid potentially slow > network requests. I mean the dolphin view of the filesystem -- the Details View Mode. I realize now that I am assuming without evidence that it displaying "0 items" under size is related to the behavior in the terminal panel. I have no direct reason to know that the two are related, and I completely understand why directory contents are not scanned until opened on remote filesystems. > rmdir is supposed to fail on nonempty directories, so the question is which > layer is wrong here. kio-fuse translates the rmdir call on directories to > KIO::del, unless it already knows that it has items. KIO::del appears to do > a recursive deletion by default, which is wrong in this context. For > directories, KIO::rmdir is probably more appropriate. This makes sense to me. I do not know fuse (other than as a user), and I may have erroneously assumed the error was related to presenting a empty directory within the mount. Thank you all for a prompt response; I've been using KDE since prior to the release of KDE 1.0, and I have always appreciated the work everybody has done and will do. I will take screenshots and any other requested documentation in the next couple hours when I am able to do so.
Git commit 830f5cb4784a2e584bbfadeabe93410f0005205c by Fabian Vogt. Committed on 08/03/2024 at 21:29. Pushed by asaoutkin into branch 'master'. Use KIO::rmdir for unlinking directories Unlike KIO::del, this fails if the directory is not empty. M +5 -3 kiofusevfs.cpp M +22 -0 tests/fileopstest.cpp https://invent.kde.org/system/kio-fuse/-/commit/830f5cb4784a2e584bbfadeabe93410f0005205c