-
Notifications
You must be signed in to change notification settings - Fork 23
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
Can't extract files to tempdir on macOs #34
Comments
I have successfully extracted files to a non-temporary directory. use unrar::Archive;
pub fn main() {
let args = std::env::args();
let file = args.skip(1).next().unwrap_or("archive.rar".to_owned());
let mut archive = Archive::new(&file).open_for_processing().unwrap();
// let temp_path = tempfile::tempdir().unwrap();
// let temp_path = temp_path.path();
let temp_path = std::path::Path::new("./tmp");
while let Some(header) = archive.read_header().expect("can't read file header") {
let temp_file_path = temp_path.join(header.entry().filename.as_path());
archive = header.extract_to(temp_file_path.as_path()).unwrap();
}
let entries = std::fs::read_dir(&temp_path).unwrap().collect::<Vec<_>>();
eprintln!("entries {:?}", entries);
} I attempted to debug the issue and found that when using tempdir(), the |
This is interesting. I have actually been using (the now unmaintained) There are 2 workarounds you can apply:
I don't know how else to proceed other than to file an issue with the RAR maintainers. |
This seems to be fixed in the v7 beta release. I checked it against both the newest v6 version (which is on crates.io right now) and the v7 beta release. The error still persists in v6 but is fixed in v7. So once the v7 is released for good we can upgrade and it will fix itself. In the meantime you can use the workarounds that I've provided. |
Issue Description
I'm unable to extract files to the temporary directory on macOS.
When I run the code provided below on macOS, I get the result
entries []
.However, when I run the same code on Linux, I get the expected result
entries [Ok(DirEntry("/tmp/.tmpbaaPum/b")), Ok(DirEntry("/tmp/.tmpbaaPum/a"))].
Environment Information:
unrar = "0.5.1"
tempfile = "3.7.1"
rustc 1.71.0 (8ede3aae2 2023-07-12)
Code
The text was updated successfully, but these errors were encountered: