forked from TrueCloudLab/rclone
core: Fix race detected by go race detector
This commit is contained in:
parent
a75bc0703f
commit
e09ef62d5b
2 changed files with 7 additions and 6 deletions
|
@ -4,7 +4,6 @@ package fs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -225,12 +224,10 @@ func Copier(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) {
|
||||||
func DeleteFiles(to_be_deleted ObjectsChan) {
|
func DeleteFiles(to_be_deleted ObjectsChan) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(Config.Transfers)
|
wg.Add(Config.Transfers)
|
||||||
var fs Fs
|
|
||||||
for i := 0; i < Config.Transfers; i++ {
|
for i := 0; i < Config.Transfers; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for dst := range to_be_deleted {
|
for dst := range to_be_deleted {
|
||||||
fs = dst.Fs()
|
|
||||||
if Config.DryRun {
|
if Config.DryRun {
|
||||||
Debug(dst, "Not deleting as --dry-run")
|
Debug(dst, "Not deleting as --dry-run")
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,8 +244,7 @@ func DeleteFiles(to_be_deleted ObjectsChan) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Log(nil, "Waiting for deletions to finish")
|
||||||
Log(fs, "Waiting for deletions to finish")
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +516,6 @@ func Purge(f Fs) error {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DeleteFiles(f.List())
|
DeleteFiles(f.List())
|
||||||
log.Printf("Deleting path")
|
|
||||||
Rmdir(f)
|
Rmdir(f)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -3,6 +3,12 @@ Remove FIXME skipping directory
|
||||||
Change lsd command so it doesn't show -1
|
Change lsd command so it doesn't show -1
|
||||||
* Make sure all Fses show -1 for objects Zero for dates etc
|
* Make sure all Fses show -1 for objects Zero for dates etc
|
||||||
|
|
||||||
|
Make unit tests for the fses
|
||||||
|
* Make them try to load a TestFSName config
|
||||||
|
* Then do a proper unit test of each one
|
||||||
|
* If there is no TestFSName config it should exit quietly
|
||||||
|
* However the Local FS should default to a tmpdir
|
||||||
|
|
||||||
Todo
|
Todo
|
||||||
* FIXME: More -dry-run checks for object transfer
|
* FIXME: More -dry-run checks for object transfer
|
||||||
* Might be quicker to check md5sums first? for swift <-> swift certainly, and maybe for small files
|
* Might be quicker to check md5sums first? for swift <-> swift certainly, and maybe for small files
|
||||||
|
|
Loading…
Reference in a new issue