A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Tar listing drops a leading ./ instead of showing a '.' folder (1016)
kolinabira961e9a129a0
diff --git a/crates/rf-archive/src/lib.rs b/crates/rf-archive/src/lib.rsindex 922d0a91..214b1407 100644--- a/crates/rf-archive/src/lib.rs+++ b/crates/rf-archive/src/lib.rs@@ -184,7 +184,7 @@ pub struct CompressOptions {/// One archive member as shown in the preview list.#[derive(Debug, Clone, PartialEq, Eq)]pub struct ArchiveEntry {- /// Name inside the archive, `/` separated, as stored (not sanitized).+ /// Name inside the archive, `/` separated, as stored (not sanitized; a tar's leading `./` is dropped).pub path: String,/// Uncompressed size (0 for directories).pub size: u64,@@ -674,8 +674,15 @@ pub fn list_with(path: &Path, opts: &Options) -> Result<Vec<ArchiveEntry>> {if !(t.is_file() || t.is_dir() || t.is_contiguous()) {continue;}+ // `tar -cf a.tar ./a.log` stores "./a.log" (and a bare "./" root entry): without the "./" the view+ // would show a folder named "." instead of the file+ let name = String::from_utf8_lossy(&e.path_bytes()).into_owned();+ let name = name.trim_start_matches("./");+ if name.is_empty() || name == "." {+ continue;+ }out.push(ArchiveEntry {- path: String::from_utf8_lossy(&e.path_bytes()).into_owned(),+ path: name.to_string(),size: if t.is_dir() { 0 } else { h.size().unwrap_or(0) },packed: 0,is_dir: t.is_dir(),@@ -2098,6 +2105,32 @@ mod tests {let _ = fs::remove_dir_all(&out);}+ /// `tar -cf a.tar ./a.log` stores the names with a leading "./", plus a "./" root entry: the listing must not show a "." folder.+ #[test]+ fn tar_listing_drops_dot_slash() {+ let d = tmp("tardot");+ let arch = d.join("a.tar");+ let mut tb = tar::Builder::new(File::create(&arch).unwrap());+ // the names are written into the header as they are (set_path would drop the "./")+ let mut put = |name: &str, dir: bool, data: &[u8]| {+ let mut h = tar::Header::new_gnu();+ h.as_old_mut().name[..name.len()].copy_from_slice(name.as_bytes());+ h.set_entry_type(if dir { tar::EntryType::Directory } else { tar::EntryType::Regular });+ h.set_size(data.len() as u64);+ h.set_mode(0o644);+ h.set_cksum();+ tb.append(&h, data).unwrap();+ };+ put("./", true, b"");+ put("./a.log", false, b"abc");+ put("./sub/b.log", false, b"de");+ tb.finish().unwrap();+ let mut paths: Vec<String> = list(&arch).unwrap().into_iter().map(|e| e.path).collect();+ paths.sort();+ assert_eq!(paths, ["a.log", "sub/b.log"]);+ let _ = fs::remove_dir_all(&d);+ }+fn pw_opts(p: &str) -> Options {Options { password: Some(p.to_string()), ..Default::default() }}