@@ -14,7 +14,7 @@ use futures::stream::{self, StreamExt as FuturesStreamExt, TryStreamExt};
1414
1515use crate :: bms:: { BMS_FILE_EXTS , BMSON_FILE_EXTS } ;
1616
17- use super :: { is_dir_having_file, is_file_same_content, lock :: acquire_disk_locks } ;
17+ use super :: { is_dir_having_file, is_file_same_content} ;
1818use log:: warn;
1919
2020/// Same name enum as Python
@@ -117,12 +117,10 @@ pub async fn move_elements_across_dir(
117117 let dir_path_ori = dir_path_ori. as_ref ( ) ;
118118 let dir_path_dst = dir_path_dst. as_ref ( ) ;
119119 // Lock and read source metadata
120- let _l_ori = acquire_disk_locks ( & [ dir_path_ori] ) . await ;
121120 let ori_md = match fs:: metadata ( & dir_path_ori) . await {
122121 Ok ( m) => m,
123122 Err ( _) => return Ok ( ( ) ) ,
124123 } ;
125- drop ( _l_ori) ;
126124
127125 if dir_path_ori == dir_path_dst {
128126 return Ok ( ( ) ) ;
@@ -134,9 +132,7 @@ pub async fn move_elements_across_dir(
134132 // Do this check BEFORE creating the target directory, otherwise we'd
135133 // unnecessarily enumerate and move children one-by-one.
136134 // Lock and read destination metadata
137- let _l_dst = acquire_disk_locks ( & [ dir_path_dst] ) . await ;
138135 let dst_meta_res = fs:: metadata ( & dir_path_dst) . await ;
139- drop ( _l_dst) ;
140136
141137 match dst_meta_res {
142138 Ok ( m) => {
@@ -148,7 +144,6 @@ pub async fn move_elements_across_dir(
148144 }
149145 Err ( e) => {
150146 if e. kind ( ) == io:: ErrorKind :: NotFound {
151- let _l = acquire_disk_locks ( & [ dir_path_ori, dir_path_dst] ) . await ;
152147 fs:: rename ( & dir_path_ori, & dir_path_dst) . await ?;
153148 return Ok ( ( ) ) ;
154149 } else {
@@ -189,9 +184,7 @@ async fn process_directory(
189184 replace_options : & ReplaceOptions ,
190185) -> io:: Result < Vec < ( PathBuf , PathBuf ) > > {
191186 // Collect entries to be processed (files / subdirectories)
192- let _l_rd = acquire_disk_locks ( & [ dir_path_ori] ) . await ;
193187 let mut entries = fs:: read_dir ( dir_path_ori) . await ?;
194- drop ( _l_rd) ;
195188 let next_folder_paths = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
196189 let mut pairs: Vec < ( PathBuf , PathBuf ) > = Vec :: new ( ) ;
197190
@@ -259,9 +252,7 @@ async fn process_directory(
259252 // Stage 2a: directory direct moves (streamed parallel)
260253 stream:: iter ( dir_direct_moves)
261254 . map ( |( src, dst) | async move {
262- let _locks = acquire_disk_locks ( & [ & src, & dst] ) . await ;
263255 let r = fs:: rename ( & src, & dst) . await . map ( |_| ( ) ) ;
264- drop ( _locks) ;
265256 r
266257 } )
267258 . buffer_unordered ( 64 )
@@ -288,9 +279,7 @@ async fn process_directory(
288279 // Stage 2c: file Rename actions (streamed parallel)
289280 stream:: iter ( file_rename_ops)
290281 . map ( |( src, dst) | async move {
291- let _locks = acquire_disk_locks ( & [ & src, & dst] ) . await ;
292282 let r = move_file_rename ( & src, & dst) . await . map ( |_| ( ) ) ;
293- drop ( _locks) ;
294283 r
295284 } )
296285 . buffer_unordered ( 128 )
@@ -303,9 +292,7 @@ async fn process_directory(
303292 . map ( |( src, dst) | {
304293 let rep = rep_clone2. clone ( ) ;
305294 async move {
306- let _locks = acquire_disk_locks ( & [ & src, & dst] ) . await ;
307295 let r = move_file ( & src, & dst, & rep) . await . map ( |_| ( ) ) ;
308- drop ( _locks) ;
309296 r
310297 }
311298 } )
@@ -325,36 +312,28 @@ async fn move_file(src: &Path, dst: &Path, rep: &ReplaceOptions) -> io::Result<(
325312
326313 match action {
327314 ReplaceAction :: Replace => {
328- let _locks = acquire_disk_locks ( & [ src, dst] ) . await ;
329315 let r = fs:: rename ( src, dst) . await ;
330- drop ( _locks) ;
331316 r
332317 }
333318 ReplaceAction :: Skip => {
334319 let exists = fs:: metadata ( & dst) . await . is_ok ( ) ;
335320 if exists {
336321 return Ok ( ( ) ) ;
337322 }
338- let _locks = acquire_disk_locks ( & [ src, dst] ) . await ;
339323 let r = fs:: rename ( src, dst) . await ;
340- drop ( _locks) ;
341324 r
342325 }
343326 ReplaceAction :: Rename => move_file_rename ( src, dst) . await ,
344327 ReplaceAction :: CheckReplace => {
345328 let dst_exists = fs:: metadata ( & dst) . await . is_ok ( ) ;
346329 if !dst_exists {
347- let _locks = acquire_disk_locks ( & [ src, dst] ) . await ;
348330 let r = fs:: rename ( src, dst) . await ;
349- drop ( _locks) ;
350331 r
351332 } else {
352333 let same = is_file_same_content ( src, dst) . await ?;
353334 if same {
354335 // Same content, directly overwrite
355- let _locks = acquire_disk_locks ( & [ src, dst] ) . await ;
356336 let r = fs:: rename ( src, dst) . await ;
357- drop ( _locks) ;
358337 r
359338 } else {
360339 move_file_rename ( src, dst) . await
@@ -382,17 +361,13 @@ async fn move_file_rename(src: &Path, dst_dir: &Path) -> io::Result<()> {
382361 } ;
383362 dst. set_file_name ( name) ;
384363 if fs:: metadata ( & dst) . await . is_err ( ) {
385- let _locks = acquire_disk_locks ( & [ src, & dst] ) . await ;
386364 fs:: rename ( src, & dst) . await ?;
387- drop ( _locks) ;
388365 return Ok ( ( ) ) ;
389366 }
390367 let same = is_file_same_content ( src, & dst) . await ?;
391368 if same {
392369 // File with same name and content already exists, skip
393- let _ls = acquire_disk_locks ( & [ src] ) . await ;
394370 fs:: remove_file ( src) . await ?;
395- drop ( _ls) ;
396371 return Ok ( ( ) ) ;
397372 }
398373 }
0 commit comments