I believe there is a race condition when recursively copying:
|
if !dir.exists() { |
|
if options.copy_inside { |
|
create_all(dir, false)?; |
|
} else { |
|
create(dir, false)?; |
|
} |
create_all will fail when the directory already exists. Having two threads copying files to the same directory, this may result in an a File exists error.
The my understanding tokio compensates for this by ignoring this case as an error: https://docs.rs/tokio/latest/tokio/fs/fn.create_dir_all.html
Notable exception is made for situations where any of the directories specified in the path could not be created as it was being created concurrently. Such cases are considered to be successful. That is, calling create_dir_all concurrently from multiple threads or processes is guaranteed not to fail due to a race condition with itself.
I think it makes sense to implement the same logic here.
I believe there is a race condition when recursively copying:
fs_extra/src/dir.rs
Lines 604 to 609 in 1754296
create_allwill fail when the directory already exists. Having two threads copying files to the same directory, this may result in an aFile existserror.The my understanding
tokiocompensates for this by ignoring this case as an error: https://docs.rs/tokio/latest/tokio/fs/fn.create_dir_all.htmlI think it makes sense to implement the same logic here.