From cbaffab9dd3029bfd18bc22a8632075949240dc2 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 27 Jul 2021 10:08:07 +0300 Subject: [PATCH] use EvalSymlinks in deleteDB --- blockstore/badger/blockstore.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/blockstore/badger/blockstore.go b/blockstore/badger/blockstore.go index 83c5012c1..6bab69915 100644 --- a/blockstore/badger/blockstore.go +++ b/blockstore/badger/blockstore.go @@ -447,26 +447,10 @@ func (b *Blockstore) doCopy(from, to *badger.DB, filter func(cid.Cid) bool) erro func (b *Blockstore) deleteDB(path string) { // follow symbolic links, otherwise the data wil be left behind - lpath := path - for { - fi, err := os.Lstat(lpath) - if err != nil { - log.Warnf("error stating %s: %s", lpath, err) - return - } - - if fi.Mode()&os.ModeSymlink == 0 { - break - } - - log.Infof("resolving symbolic link %s", lpath) - newpath, err := os.Readlink(lpath) - if err != nil { - log.Warnf("error resolving symbolic link %s: %s", lpath, err) - return - } - log.Infof("resolved symbolic link %s -> %s", lpath, newpath) - lpath = newpath + lpath, err := filepath.EvalSymlinks(path) + if err != nil { + log.Warnf("error resolving symlinks in %s", path) + return } log.Infof("removing data directory %s", lpath)