File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -601,13 +601,25 @@ async fn ax_post_file(
601601 let hdr_content_type = headers. get ( "Content-Type-Upstream" ) ;
602602 let semaphore = get_or_create_semaphore ( & state. file_locks , & full_path) . await ;
603603
604- // Try to acquire permit - fails immediately if upload in progress
605- let _permit = match semaphore. try_acquire ( ) {
606- Ok ( permit) => permit,
604+ // Try to acquire permit - wait for up to 30 seconds
605+ let _permit = match tokio:: time:: timeout (
606+ tokio:: time:: Duration :: from_secs ( 30 ) ,
607+ semaphore. acquire ( ) ,
608+ )
609+ . await
610+ {
611+ Ok ( Ok ( permit) ) => permit,
612+ Ok ( Err ( _) ) => {
613+ upload_result = Some ( (
614+ StatusCode :: INTERNAL_SERVER_ERROR ,
615+ "Semaphore closed" . to_string ( ) . into_bytes ( ) ,
616+ ) ) ;
617+ break ;
618+ }
607619 Err ( _) => {
608620 upload_result = Some ( (
609621 StatusCode :: CONFLICT ,
610- "Upload already in progress " . to_string ( ) . into_bytes ( ) ,
622+ "Timeout waiting for upload " . to_string ( ) . into_bytes ( ) ,
611623 ) ) ;
612624 break ;
613625 }
You can’t perform that action at this time.
0 commit comments