This commit is contained in:
Anna 2022-09-17 01:14:10 -04:00
parent 36eb675091
commit 170604b463
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
1 changed files with 12 additions and 10 deletions

View File

@ -38,17 +38,19 @@ pub fn main() {
temp.seek(SeekFrom::Start(0)).unwrap();
let hash = sha.finalize_reset();
let hash = hex::encode(&*hash);
if !hashes.contains_key(&hash) {
let new = !hashes.contains_key(&hash);
let saved = SavedFile {
author: extractor.manifest().author.clone(),
package: extractor.manifest().name.clone(),
package_version: extractor.manifest().version.clone(),
game_path: file.file.full_path.clone(),
group: file.group.map(ToOwned::to_owned),
option: file.option.map(ToOwned::to_owned),
};
hashes.entry(hash.clone()).or_default().push(saved);
if new {
let path = Path::new("files").join(&hash);
let saved = SavedFile {
author: extractor.manifest().author.clone(),
package: extractor.manifest().name.clone(),
package_version: extractor.manifest().version.clone(),
game_path: file.file.full_path.clone(),
group: file.group.map(ToOwned::to_owned),
option: file.option.map(ToOwned::to_owned),
};
hashes.entry(hash).or_default().push(saved);
std::io::copy(&mut temp, &mut File::create(&path).unwrap()).unwrap();
// std::fs::write(&path, data).unwrap();
println!("writing {}", path.to_string_lossy());