From 0631804e005c5ad650ccf92b22ca4306cf386b33 Mon Sep 17 00:00:00 2001 From: zu1k Date: Thu, 6 Oct 2022 13:09:41 +0800 Subject: [PATCH] fix: migration move db to data dir Signed-off-by: zu1k --- internal/migration/v6.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/migration/v6.go b/internal/migration/v6.go index 0108f1d..4fa0510 100644 --- a/internal/migration/v6.go +++ b/internal/migration/v6.go @@ -17,6 +17,7 @@ func migration2v6() { _, 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") stat, err := os.Stat(oldDefaultConfigPath) if err == nil { @@ -24,14 +25,16 @@ func migration2v6() { _ = os.Rename(oldDefaultConfigPath, filepath.Join(constant.ConfigDirPath, "config.yaml")) } } + files, err := os.ReadDir(oldDefaultWorkPath) if err == nil { for _, file := range files { if file.Type().IsRegular() { - _ = os.Rename(filepath.Join(oldDefaultWorkPath, file.Name()), filepath.Join(constant.ConfigDirPath, file.Name())) + _ = os.Rename(filepath.Join(oldDefaultWorkPath, file.Name()), filepath.Join(constant.DataDirPath, file.Name())) } } } + err = os.RemoveAll(oldDefaultWorkPath) if err != nil { log.Errorf("Auto migration failed: %s\n", err)