From 5d4c14a5d5949dfeb6b0a5e5852a9e621ac5f74e Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:45:22 +0530 Subject: [PATCH] Fix DB path --- main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 6424aea40..2147afde9 100644 --- a/main.go +++ b/main.go @@ -27,12 +27,14 @@ func main() { if err != nil { log.Fatalf("Could not create cli config path\n%v\n", err) } - oldCliPath := fmt.Sprintf("%sente-cli.db", cliDBPath) newCliPath := fmt.Sprintf("%s/ente-cli.db", cliDBPath) - if _, err := os.Stat(oldCliPath); err == nil { - log.Printf("migrating old cli db from %s to %s\n", oldCliPath, newCliPath) - if err := os.Rename(oldCliPath, newCliPath); err != nil { - log.Fatalf("Could not rename old cli db\n%v\n", err) + if !strings.HasPrefix(cliDBPath, "/") { + oldCliPath := fmt.Sprintf("%sente-cli.db", cliDBPath) + if _, err := os.Stat(oldCliPath); err == nil { + log.Printf("migrating old cli db from %s to %s\n", oldCliPath, newCliPath) + if err := os.Rename(oldCliPath, newCliPath); err != nil { + log.Fatalf("Could not rename old cli db\n%v\n", err) + } } } db, err := pkg.GetDB(newCliPath)