@@ -37,7 +37,6 @@ use crate::rate_limiter::LimitedAction;
3737use crate :: schema:: * ;
3838use crate :: sql:: canon_crate_name;
3939use crate :: util:: errors:: { bad_request, custom, internal, AppResult , BoxedAppError } ;
40- use crate :: util:: Maximums ;
4140use crate :: views:: {
4241 EncodableCrate , EncodableCrateDependency , GoodCrate , PublishMetadata , PublishWarnings ,
4342} ;
@@ -142,18 +141,17 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go
142141 . check_rate_limit ( auth. user ( ) . id , rate_limit_action, & mut conn)
143142 . await ?;
144143
145- let maximums = Maximums :: new (
146- existing_crate. as_ref ( ) . and_then ( |c| c. max_upload_size ) ,
147- app. config . max_upload_size ,
148- app. config . max_unpack_size ,
149- ) ;
144+ let max_upload_size = existing_crate
145+ . as_ref ( )
146+ . and_then ( |c| c. max_upload_size ( ) )
147+ . unwrap_or ( app. config . max_upload_size ) ;
150148
151- let tarball_bytes = read_tarball_bytes ( & mut reader, maximums . max_upload_size as u32 ) . await ?;
149+ let tarball_bytes = read_tarball_bytes ( & mut reader, max_upload_size) . await ?;
152150 let content_length = tarball_bytes. len ( ) as u64 ;
153151
154152 let pkg_name = format ! ( "{}-{}" , & * metadata. name, & version_string) ;
155- let tarball_info =
156- process_tarball ( & pkg_name, & * tarball_bytes, maximums . max_unpack_size ) . await ?;
153+ let max_unpack_size = std :: cmp :: max ( app . config . max_unpack_size , max_upload_size as u64 ) ;
154+ let tarball_info = process_tarball ( & pkg_name, & * tarball_bytes, max_unpack_size) . await ?;
157155
158156 // `unwrap()` is safe here since `process_tarball()` validates that
159157 // we only accept manifests with a `package` section and without
0 commit comments