From 329bd244d25ae3d1d5b72c044df19d92f150f39b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 14 Dec 2023 19:38:21 +0200 Subject: [PATCH] lib/fs: remove unused IsEmptyDir() This function became unused after the commit 43b24164efdd35c2641a289ab93f5cb94279cb60 The unused function has been found with deadode tool - https://go.dev/blog/deadcode --- lib/fs/fs.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lib/fs/fs.go b/lib/fs/fs.go index 22e5bce1da..101a8a868d 100644 --- a/lib/fs/fs.go +++ b/lib/fs/fs.go @@ -190,24 +190,6 @@ func mustSyncParentDirIfExists(path string) { MustSyncPath(parentDirPath) } -// IsEmptyDir returns true if path points to empty directory. -func IsEmptyDir(path string) bool { - // See https://stackoverflow.com/a/30708914/274937 - f, err := os.Open(path) - if err != nil { - logger.Panicf("FATAL: cannot open dir: %s", err) - } - _, err = f.Readdirnames(1) - MustClose(f) - if err != nil { - if err == io.EOF { - return true - } - logger.Panicf("FATAL: unexpected error when reading directory %q: %s", path, err) - } - return false -} - // MustRemoveDirAtomic removes the given dir atomically. // // It uses the following algorithm: