From 745eda9e87453691709baabb19633737b84cde2f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 24 May 2021 04:51:54 +0300 Subject: [PATCH] lib/fs: do not pass done callback to tryRemoveAll() func This improves code readability a bit. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1313 --- lib/fs/dir_remover.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/fs/dir_remover.go b/lib/fs/dir_remover.go index 72f1c9484..ba3e8d52e 100644 --- a/lib/fs/dir_remover.go +++ b/lib/fs/dir_remover.go @@ -11,7 +11,8 @@ import ( ) func mustRemoveAll(path string, done func()) { - if tryRemoveAll(path, done) { + if tryRemoveAll(path) { + done() return } select { @@ -27,7 +28,8 @@ func mustRemoveAll(path string, done func()) { }() for { time.Sleep(time.Second) - if tryRemoveAll(path, done) { + if tryRemoveAll(path) { + done() return } } @@ -36,13 +38,12 @@ func mustRemoveAll(path string, done func()) { var dirRemoverWG syncwg.WaitGroup -func tryRemoveAll(path string, done func()) bool { +func tryRemoveAll(path string) bool { err := os.RemoveAll(path) if err == nil || isStaleNFSFileHandleError(err) { // Make sure the parent directory doesn't contain references // to the current directory. mustSyncParentDirIfExists(path) - done() return true } if !isTemporaryNFSError(err) {