-
Notifications
You must be signed in to change notification settings - Fork 30
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
Invalid original path #47
Comments
It seems to work as expected, also on linux.
Thanks for posting. This issue doesn't reproduce for me though, and I tested it on three platforms. Can you help? |
I cloned the repo and ran
I took a quick look at the source, did few println's and noticed that variable value in freedesktop.rs (line 168) is something like this:
And few lines later at line 173 in if statement:
Results value_path to be incorrect:
I don't have more time to put in this right now but i hope it helps. Repo is cloned into /home/myuser/temp/trash-rs to be clear. |
I setup a Fedora 34 VM and could reproduce the restore errors, while also noticing the oddly named names for test files. That should make it fixable. |
I added a few more debug prints and arrived at the same conclusion: it is unable to calculate the correct original path from the values it sees in the trash info files. This makes any restore generally fail. Here is the output for completeness.
|
For some reason, on some unixes and in some 'trash' folders the original file paths include the user name and the trash directory itself is buried in .local/share. This violates the previous assumption that the trash folder is in the users home and leads to invalid original paths, causing restore to fail. Now that I am thinking about it… isn't it use who write the trash info file?
…f those were relative (#47) Previously it would be unable to reconstruct original paths if the trash directory was on a mount point due to a 'split brain' of sorts. When trashing files it would create original path information based on them being relative to a mount point, but when restoring them it would reconstruct them to be relative to the trash top level directory. Now the reconstruction happens against to mount point itself which makes restoration match.
This is fixed in v2.1.1, maybe you can give it a try. The cause was improper handling of relative original paths which would occour if the deleted file was on a mount point. This is the case on ubuntu, but not on other systems. Nonetheless, this also means that all restore operations would fail on any mount point, which is probably very likely. |
I ran tests without errors on Fedora, Arch, and EndeavourOS, but the path is still wrong on Fedora and Arch and files restore to ~/.local/share/what-ever. Somehow on Endeavour this doesn't happen and everything works as intended. |
I think i found the problem freedesktop.rs line 428:
i dont understand the whole encoding and trimming before this (maybe it isn't needed at all?) but here when writing the info file content, instead of using path, use absolute_uri, and it seems to work properly:
|
Thanks for the hint and for digging in! Let's try that via v2.1.2. |
Seems to be fixed on all distros i mentioned, thanks for fast updates! |
Running the code from example:
File goes to the trash bin but original path is wrong and file cant be restored. Real original path:
original path shown in trashed file:
platform: linux
trash-rs: 2.0.4
rust: 1.60.0 (7737e0b5c 2022-04-04)
The text was updated successfully, but these errors were encountered: