Skip to content

Commit

Permalink
feat(libscoop): Adpot new cache filename format
Browse files Browse the repository at this point in the history
which is used by Scoop v0.5.0+

Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Jul 22, 2024
1 parent 4ed662e commit 15172a9
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions crates/libscoop/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) mod resolve;
pub(crate) mod sync;

use once_cell::unsync::OnceCell;
use std::fmt;
use std::{fmt, path::PathBuf};

pub use manifest::{InstallInfo, License, Manifest};
pub use query::QueryOption;
Expand Down Expand Up @@ -201,12 +201,21 @@ impl Package {
.url()
.into_iter()
.map(|u| {
format!(
"{}#{}#{}",
self.name(),
self.version(),
internal::fs::filenamify(u)
)
let mut hasher = scoop_hash::ChecksumBuilder::new().sha256().build();
hasher.consume(u.as_bytes());
let mut hash = hasher.finalize();
hash.truncate(7);
let path = PathBuf::from(u);
let mut ext = path
.extension()
.unwrap_or_default()
.to_string_lossy()
.to_string();
if !ext.is_empty() {
ext.insert(0, '.');
}

format!("{}#{}#{}{}", self.name(), self.version(), hash, ext)
})
.collect::<Vec<_>>()
}
Expand Down

0 comments on commit 15172a9

Please sign in to comment.