mirror of
https://github.com/zu1k/nali.git
synced 2025-02-02 10:22:41 +08:00
fix: migration move db to data dir
Signed-off-by: zu1k <i@zu1k.com>
This commit is contained in:
parent
5039161a5c
commit
0631804e00
@ -17,6 +17,7 @@ func migration2v6() {
|
|||||||
_, err = os.Stat(oldDefaultWorkPath)
|
_, err = os.Stat(oldDefaultWorkPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
println("Old data directories are detected and will attempt to migrate automatically")
|
println("Old data directories are detected and will attempt to migrate automatically")
|
||||||
|
|
||||||
oldDefaultConfigPath := filepath.Join(oldDefaultWorkPath, "config.yaml")
|
oldDefaultConfigPath := filepath.Join(oldDefaultWorkPath, "config.yaml")
|
||||||
stat, err := os.Stat(oldDefaultConfigPath)
|
stat, err := os.Stat(oldDefaultConfigPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -24,14 +25,16 @@ func migration2v6() {
|
|||||||
_ = os.Rename(oldDefaultConfigPath, filepath.Join(constant.ConfigDirPath, "config.yaml"))
|
_ = os.Rename(oldDefaultConfigPath, filepath.Join(constant.ConfigDirPath, "config.yaml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := os.ReadDir(oldDefaultWorkPath)
|
files, err := os.ReadDir(oldDefaultWorkPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if file.Type().IsRegular() {
|
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)
|
err = os.RemoveAll(oldDefaultWorkPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Auto migration failed: %s\n", err)
|
log.Errorf("Auto migration failed: %s\n", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user