mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-02 19:54:54 -06:00
Check directory existence again when failing to create it to avoid erroring out on race condition
This commit is contained in:
@@ -93,7 +93,6 @@ function add_file()
|
|||||||
FILE_NAME=$1
|
FILE_NAME=$1
|
||||||
pushd ${TEST_REPO}
|
pushd ${TEST_REPO}
|
||||||
dd if=/dev/urandom of=${FILE_NAME} bs=1000 count=20000
|
dd if=/dev/urandom of=${FILE_NAME} bs=1000 count=20000
|
||||||
echo ${FILE_NAME} > "${FILE_NAME}"
|
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
integration_tests/threaded_test.sh
Executable file
17
integration_tests/threaded_test.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
. ./test_functions.sh
|
||||||
|
|
||||||
|
fixture
|
||||||
|
|
||||||
|
pushd ${TEST_REPO}
|
||||||
|
${DUPLICACY} init integration-tests $TEST_STORAGE -c 1k
|
||||||
|
|
||||||
|
add_file file3
|
||||||
|
add_file file4
|
||||||
|
|
||||||
|
|
||||||
|
${DUPLICACY} backup -threads 16
|
||||||
|
${DUPLICACY} check --files -stats
|
||||||
|
popd
|
||||||
@@ -158,8 +158,12 @@ func (storage *FileStorage) FindChunk(threadIndex int, chunkID string, isFossil
|
|||||||
|
|
||||||
err = os.Mkdir(subDir, 0744)
|
err = os.Mkdir(subDir, 0744)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// The directory may have been created by other threads so check it again.
|
||||||
|
stat, _ := os.Stat(subDir)
|
||||||
|
if stat == nil || !stat.IsDir() {
|
||||||
return "", false, 0, err
|
return "", false, 0, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dir = subDir
|
dir = subDir
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -215,8 +215,12 @@ func (storage *SFTPStorage) FindChunk(threadIndex int, chunkID string, isFossil
|
|||||||
|
|
||||||
err = storage.client.Mkdir(subDir)
|
err = storage.client.Mkdir(subDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// The directory may have been created by other threads so check it again.
|
||||||
|
stat, _ := storage.client.Stat(subDir)
|
||||||
|
if stat == nil || !stat.IsDir() {
|
||||||
return "", false, 0, fmt.Errorf("Failed to create the directory %s: %v", subDir, err)
|
return "", false, 0, fmt.Errorf("Failed to create the directory %s: %v", subDir, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dir = subDir
|
dir = subDir
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user