From 5039161a5c41f4bebb159d756649516cdbd5e8c9 Mon Sep 17 00:00:00 2001 From: zu1k Date: Thu, 6 Oct 2022 13:05:35 +0800 Subject: [PATCH] fix: migration find old dir path Signed-off-by: zu1k --- internal/migration/v6.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/migration/v6.go b/internal/migration/v6.go index c785eef..0108f1d 100644 --- a/internal/migration/v6.go +++ b/internal/migration/v6.go @@ -8,10 +8,13 @@ import ( "github.com/zu1k/nali/internal/constant" ) -const oldDefaultWorkPath = "~/.nali/" - func migration2v6() { - _, err := os.Stat(oldDefaultWorkPath) + homeDir, err := os.UserHomeDir() + if err != nil { + return + } + oldDefaultWorkPath := filepath.Join(homeDir, ".nali") + _, err = os.Stat(oldDefaultWorkPath) if err == nil { println("Old data directories are detected and will attempt to migrate automatically") oldDefaultConfigPath := filepath.Join(oldDefaultWorkPath, "config.yaml")