mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/fs: do not pass done callback to tryRemoveAll() func
This improves code readability a bit. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1313
This commit is contained in:
parent
402a8ca710
commit
745eda9e87
1 changed files with 5 additions and 4 deletions
|
@ -11,7 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func mustRemoveAll(path string, done func()) {
|
func mustRemoveAll(path string, done func()) {
|
||||||
if tryRemoveAll(path, done) {
|
if tryRemoveAll(path) {
|
||||||
|
done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
@ -27,7 +28,8 @@ func mustRemoveAll(path string, done func()) {
|
||||||
}()
|
}()
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
if tryRemoveAll(path, done) {
|
if tryRemoveAll(path) {
|
||||||
|
done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,13 +38,12 @@ func mustRemoveAll(path string, done func()) {
|
||||||
|
|
||||||
var dirRemoverWG syncwg.WaitGroup
|
var dirRemoverWG syncwg.WaitGroup
|
||||||
|
|
||||||
func tryRemoveAll(path string, done func()) bool {
|
func tryRemoveAll(path string) bool {
|
||||||
err := os.RemoveAll(path)
|
err := os.RemoveAll(path)
|
||||||
if err == nil || isStaleNFSFileHandleError(err) {
|
if err == nil || isStaleNFSFileHandleError(err) {
|
||||||
// Make sure the parent directory doesn't contain references
|
// Make sure the parent directory doesn't contain references
|
||||||
// to the current directory.
|
// to the current directory.
|
||||||
mustSyncParentDirIfExists(path)
|
mustSyncParentDirIfExists(path)
|
||||||
done()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if !isTemporaryNFSError(err) {
|
if !isTemporaryNFSError(err) {
|
||||||
|
|
Loading…
Reference in a new issue