I'm getting an error when trying to run extract() on a subdir.
My setup is something like this: I have a main folder a, with a subdir b inside it. If I get the subdir with included_dir.get_dir("b") and then attempt to run extract() on it, I get an OS error: "No such file or directory"
The extract method looks like this:
/// Create directories and extract all files to real filesystem.
/// Creates parent directories of `path` if they do not already exist.
/// Fails if some files already exist.
/// In case of error, partially extracted directory may remain on the filesystem.
pub fn extract<S: AsRef<Path>>(&self, base_path: S) -> std::io::Result<()> {
let base_path = base_path.as_ref();
for entry in self.entries() {
let path = base_path.join(entry.path());
match entry {
DirEntry::Dir(d) => {
fs::create_dir_all(&path)?;
d.extract(base_path)?;
}
DirEntry::File(f) => {
fs::write(path, f.contents())?;
}
}
}
Ok(())
}
The issue seems to be that it's coming across a DirEntry::File before a DirEntry::Dir, so the directory creation step isn't happening first and creating the file fails.
Besides this issue, it also seems like if it did succeed, it would be using the whole path, rather than just starting at the subdir (i.e. in my example, I would end up with b/file.txt in base_path rather than just file.txt), which I don't think is ideal.
I'm getting an error when trying to run
extract()on a subdir.My setup is something like this: I have a main folder
a, with a subdirbinside it. If I get the subdir withincluded_dir.get_dir("b")and then attempt to runextract()on it, I get an OS error: "No such file or directory"The extract method looks like this:
The issue seems to be that it's coming across a
DirEntry::Filebefore aDirEntry::Dir, so the directory creation step isn't happening first and creating the file fails.Besides this issue, it also seems like if it did succeed, it would be using the whole path, rather than just starting at the subdir (i.e. in my example, I would end up with
b/file.txtinbase_pathrather than justfile.txt), which I don't think is ideal.