@@ -1291,8 +1291,6 @@ impl PluginInstaller {
12911291 . into ( ) ) ;
12921292 }
12931293 let revision = revision. as_deref ( ) . unwrap_or ( "main" ) ;
1294- let expected_sha256 =
1295- if files. len ( ) == 1 { model. sha256 . as_deref ( ) } else { None } ;
12961294 for file in files {
12971295 if cancel. is_cancelled ( ) {
12981296 return Err ( InstallError :: Cancelled ) ;
@@ -1301,6 +1299,11 @@ impl PluginInstaller {
13011299 if !is_safe_relative_path ( file_path) {
13021300 return Err ( anyhow ! ( "Invalid model file path '{file}'" ) . into ( ) ) ;
13031301 }
1302+ let expected_sha256 = model
1303+ . file_checksums
1304+ . get ( file. as_str ( ) )
1305+ . map ( String :: as_str)
1306+ . or ( if files. len ( ) == 1 { model. sha256 . as_deref ( ) } else { None } ) ;
13041307 let target_path = self . models_dir . join ( file_path) ;
13051308 let display_name = file. as_str ( ) ;
13061309 let url = huggingface_model_url ( repo_id, revision, file) ?;
@@ -1970,6 +1973,7 @@ fn now_ms() -> u128 {
19701973mod tests {
19711974 use super :: * ;
19721975 use anyhow:: { anyhow, bail, Context , Result } ;
1976+ use std:: collections:: HashMap ;
19731977 use std:: sync:: Arc ;
19741978
19751979 use crate :: plugins:: UnifiedPluginManager ;
@@ -2160,6 +2164,7 @@ mod tests {
21602164 source: crate :: marketplace:: ModelSource :: Url { url: url. clone( ) } ,
21612165 expected_size_bytes: Some ( payload. len( ) as u64 ) ,
21622166 sha256: Some ( hash) ,
2167+ file_checksums: HashMap :: new( ) ,
21632168 license: None ,
21642169 license_url: None ,
21652170 gated: false ,
@@ -2256,6 +2261,7 @@ mod tests {
22562261 source: crate :: marketplace:: ModelSource :: Url { url: url. clone( ) } ,
22572262 expected_size_bytes: Some ( payload. len( ) as u64 ) ,
22582263 sha256: Some ( hash) ,
2264+ file_checksums: HashMap :: new( ) ,
22592265 license: None ,
22602266 license_url: None ,
22612267 gated: false ,
@@ -2319,6 +2325,7 @@ mod tests {
23192325 } ,
23202326 expected_size_bytes: None ,
23212327 sha256: None ,
2328+ file_checksums: HashMap :: new( ) ,
23222329 license: None ,
23232330 license_url: None ,
23242331 gated: true ,
0 commit comments