@@ -396,7 +396,7 @@ async fn ax_post_file(headers: HeaderMap, State(state): State<AppState>, mut mul
396396 let mut path: String = "" . to_string ( ) ;
397397 let mut file0: Vec < u8 > = Vec :: new ( ) ;
398398 let mut file0_filename: String = "" . to_string ( ) ;
399- let full_path = format ! ( "{}/{}" , path , file0_filename ) ;
399+
400400
401401 // verify upload permissions, some users have upload permissions only for certain prefix(path)
402402 // check config.toml for upload_prefixes
@@ -405,15 +405,6 @@ async fn ax_post_file(headers: HeaderMap, State(state): State<AppState>, mut mul
405405 Err ( e) => return ( StatusCode :: FORBIDDEN , e. to_string ( ) . into_bytes ( ) ) ,
406406 }
407407
408- let semaphore = get_or_create_semaphore ( & state. file_locks , & full_path) . await ;
409-
410- // Try to acquire permit - fails immediately if upload in progress
411- let permit = match semaphore. try_acquire ( ) {
412- Ok ( permit) => permit,
413- Err ( _) => {
414- return ( StatusCode :: CONFLICT , "Upload already in progress" . to_string ( ) . into_bytes ( ) ) ;
415- }
416- } ;
417408
418409 while let Some ( field) = multipart. next_field ( ) . await . unwrap ( ) {
419410 let name = field. name ( ) . unwrap ( ) . to_string ( ) ;
@@ -459,7 +450,18 @@ async fn ax_post_file(headers: HeaderMap, State(state): State<AppState>, mut mul
459450 path. pop ( ) ;
460451 }
461452
453+ let full_path = format ! ( "{}/{}" , path, file0_filename) ;
462454 let hdr_content_type = headers. get ( "Content-Type-Upstream" ) ;
455+ let semaphore = get_or_create_semaphore ( & state. file_locks , & full_path) . await ;
456+
457+ // Try to acquire permit - fails immediately if upload in progress
458+ let permit = match semaphore. try_acquire ( ) {
459+ Ok ( permit) => permit,
460+ Err ( _) => {
461+ return ( StatusCode :: CONFLICT , "Upload already in progress" . to_string ( ) . into_bytes ( ) ) ;
462+ }
463+ } ;
464+
463465 let content_type: String = match hdr_content_type {
464466 Some ( content_type) => {
465467 println ! ( "Content-Type: {:?}" , content_type) ;
0 commit comments