mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Limit alterfiles to a single operation per file
This commit is contained in:
parent
dedca59ac9
commit
58b15f9452
17
test/util.go
17
test/util.go
@ -134,9 +134,7 @@ func alterFiles(dir string) error {
|
||||
case r == 0 && comps > 2:
|
||||
// Delete every tenth file or directory, except top levels
|
||||
err := removeAll(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
|
||||
case r == 1 && info.Mode().IsRegular():
|
||||
if info.Mode()&0200 != 0200 {
|
||||
@ -162,9 +160,7 @@ func alterFiles(dir string) error {
|
||||
return err
|
||||
}
|
||||
err = fd.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
|
||||
// Change capitalization
|
||||
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
||||
@ -177,9 +173,7 @@ func alterFiles(dir string) error {
|
||||
}
|
||||
}
|
||||
err = os.Rename(path, strings.Replace(path, filepath.Base(path), string(base), 1))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
|
||||
// Switch between files and directories
|
||||
case r == 2 && comps > 3 && rand.Float64() < 0.2:
|
||||
@ -204,6 +198,7 @@ func alterFiles(dir string) error {
|
||||
}
|
||||
generateFiles(path, 10, 20, "../LICENSE")
|
||||
}
|
||||
return err
|
||||
|
||||
case r == 3 && comps > 2 && (info.Mode().IsRegular() || rand.Float64() < 0.2):
|
||||
rpath := filepath.Dir(path)
|
||||
@ -213,9 +208,7 @@ func alterFiles(dir string) error {
|
||||
}
|
||||
}
|
||||
err = os.Rename(path, filepath.Join(rpath, randomName()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user