Fix compression algos not being written

This commit is contained in:
Truman Kilen 2023-02-10 19:48:55 -06:00
parent 9692c7a4d1
commit 8fddd3961f
2 changed files with 15 additions and 3 deletions

View file

@ -89,8 +89,17 @@ impl Footer {
ver if ver < Version::V8B => 4, ver if ver < Version::V8B => 4,
_ => 5, _ => 5,
}; };
for _ in 0..algo_size { // TODO: handle if compression.len() > algo_size
writer.write_all(&[0; 32])?; for i in 0..algo_size {
let mut name = [0; 32];
if let Some(algo) = self.compression.get(i) {
if algo != &Compression::None {
for (i, b) in algo.to_string().as_bytes().iter().enumerate() {
name[i] = *b;
}
}
}
writer.write_all(&name)?;
} }
Ok(()) Ok(())
} }

View file

@ -23,6 +23,7 @@ pub struct Pak {
version: Version, version: Version,
mount_point: String, mount_point: String,
index: Index, index: Index,
compression: Vec<super::Compression>,
} }
impl Pak { impl Pak {
@ -31,6 +32,7 @@ impl Pak {
version, version,
mount_point, mount_point,
index: Index::new(path_hash_seed), index: Index::new(path_hash_seed),
compression: vec![],
} }
} }
} }
@ -310,6 +312,7 @@ impl Pak {
version, version,
mount_point, mount_point,
index, index,
compression: footer.compression,
}) })
} }
@ -440,7 +443,7 @@ impl Pak {
index_size: index_buf.len() as u64, index_size: index_buf.len() as u64,
hash: index_hash, hash: index_hash,
frozen: false, frozen: false,
compression: vec![], compression: self.compression.clone(), // TODO: avoid this clone
}; };
footer.write(writer)?; footer.write(writer)?;