mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
sftp: fix directory creation races
If mkdir fails then before this change it would have thrown an error. After this change, if the error indicated that the directory already exists then the error is not returned to the user. This fixes a race condition when two rclone threads are trying to create the same directory.
This commit is contained in:
parent
6ce0168ba5
commit
67240bd541
@ -1171,6 +1171,10 @@ func (f *Fs) mkdir(ctx context.Context, dirPath string) error {
|
|||||||
err = c.sftpClient.Mkdir(dirPath)
|
err = c.sftpClient.Mkdir(dirPath)
|
||||||
f.putSftpConnection(&c, err)
|
f.putSftpConnection(&c, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if os.IsExist(err) {
|
||||||
|
fs.Debugf(f, "directory %q exists after Mkdir is attempted", dirPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("mkdir %q failed: %w", dirPath, err)
|
return fmt.Errorf("mkdir %q failed: %w", dirPath, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user