@@ -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} ;
@@ -146,18 +145,18 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go
146145 . check_rate_limit ( auth. user ( ) . id , rate_limit_action, & mut conn)
147146 . await ?;
148147
149- let maximums = Maximums :: new (
150- existing_crate . as_ref ( ) . and_then ( |c| c . max_upload_size ) ,
151- app . config . max_upload_size ,
152- app . config . max_unpack_size ,
153- ) ;
148+ let max_upload_size = existing_crate
149+ . as_ref ( )
150+ . and_then ( |c| c . max_upload_size )
151+ . and_then ( |m| u32 :: try_from ( m ) . ok ( ) )
152+ . unwrap_or ( app . config . max_upload_size ) ;
154153
155- let tarball_bytes = read_tarball_bytes ( & mut reader, maximums . max_upload_size ) . await ?;
154+ let tarball_bytes = read_tarball_bytes ( & mut reader, max_upload_size) . await ?;
156155 let content_length = tarball_bytes. len ( ) as u64 ;
157156
158157 let pkg_name = format ! ( "{}-{}" , & * metadata. name, & version_string) ;
159- let tarball_info =
160- process_tarball ( & pkg_name, & * tarball_bytes, maximums . max_unpack_size ) . await ?;
158+ let max_unpack_size = std :: cmp :: max ( app . config . max_unpack_size , max_upload_size as u64 ) ;
159+ let tarball_info = process_tarball ( & pkg_name, & * tarball_bytes, max_unpack_size) . await ?;
161160
162161 // `unwrap()` is safe here since `process_tarball()` validates that
163162 // we only accept manifests with a `package` section and without
0 commit comments