diff --git a/backhand-test/tests/issues.rs b/backhand-test/tests/issues.rs index b8d3496e..e6d67aca 100644 --- a/backhand-test/tests/issues.rs +++ b/backhand-test/tests/issues.rs @@ -6,3 +6,14 @@ fn issue_275() { let mut fs = backhand::FilesystemWriter::default(); fs.write(&mut writer).unwrap(); } + +/// https://github.com/wcampbell0x2a/backhand/issues/359 +#[test] +#[cfg(feature = "xz")] +fn issue_359() { + let mut writer = std::io::Cursor::new(vec![]); + let mut fs = backhand::FilesystemWriter::default(); + let header = backhand::NodeHeader { permissions: 0, uid: 1, gid: 2, mtime: 3 }; + fs.push_dir_all("a/b/c/d/e/f/g", header).unwrap(); + fs.write(&mut writer).unwrap(); +} diff --git a/backhand/src/filesystem/writer.rs b/backhand/src/filesystem/writer.rs index 61aaa659..9c590385 100644 --- a/backhand/src/filesystem/writer.rs +++ b/backhand/src/filesystem/writer.rs @@ -350,16 +350,7 @@ impl<'a, 'b> FilesystemWriter<'a, 'b> { } } //if the dir don't exists, create it - Err(index) => { - self.root.nodes.insert( - index, - Node::new( - file.to_path_buf(), - header, - InnerNode::Dir(SquashfsDir::default()), - ), - ); - } + Err(_index) => self.push_dir(file, header)?, } } Ok(())