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

Unable to delete file on Windows shared folder #55

Open
lucatrv opened this issue Aug 7, 2022 · 4 comments
Open

Unable to delete file on Windows shared folder #55

lucatrv opened this issue Aug 7, 2022 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@lucatrv
Copy link

lucatrv commented Aug 7, 2022

I tried to delete a file on a Windows shared folder (it is on a NAS, shared through Samba). I get the following error message:

Error during a trash operation: Unknown { description: "windows error: Impossibile trovare il file specificato.\r\n" }

@Byron Byron added the question Further information is requested label Aug 8, 2022
@Byron
Copy link
Owner

Byron commented Aug 8, 2022

Thanks for letting us know. What's the version of this crate you were using? Is there a minimal program you can post here that would reproduce the issue, assuming the file to be deleted is on a Samba mount? Thanks.

@lucatrv
Copy link
Author

lucatrv commented Aug 8, 2022

Z: is a Samba mount and Z:\z.txt is an empty file.

The following code:

use trash;

fn main() {
    trash::delete(r"Z:\z.txt").unwrap();
}

errors out with message:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Unknown { description: "windows error: Impossibile trovare il file specificato.\r\n" }

while the following code works:

use std::fs;

fn main() {
    fs::remove_file(r"Z:\z.txt").unwrap();
}

I'm on:

  • Windows 10 x64
  • rustc 1.62.1
  • trash 2.1.5

@Byron Byron added help wanted Extra attention is needed and removed question Further information is requested labels Aug 9, 2022
@Byron
Copy link
Owner

Byron commented Aug 9, 2022

Thanks a lot, that should help.

Note: I have a hunch this is related to a path-processing step happening when using trash, maybe canonicalization. There is an alternative implementation of this, git_path::realpath() or git_path::absolutize() which could be tried if this really is the case.

@lucatrv
Copy link
Author

lucatrv commented Aug 9, 2022

For your info, when you delete a file on a shared folder from Windows File Explorer, the file is deleted permanently and not moved to the trash bin. I guess this is to avoid copying files through the network. So when a file is on a shared folder maybe you could just issue std::fs::remove_file directly.
The best solution however would be to add an option, with default to delete permanently, otherwise to copy through network and move to the local trash bin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants