Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export NALI_HOME=~/.nali 时,会删除目录 #155

Closed
wen-long opened this issue Dec 14, 2022 · 1 comment
Closed

export NALI_HOME=~/.nali 时,会删除目录 #155

wen-long opened this issue Dec 14, 2022 · 1 comment

Comments

@wen-long
Copy link

func migration2v6() {
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")
stat, err := os.Stat(oldDefaultConfigPath)
if err == nil {
if stat.Mode().IsRegular() {
_ = 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.DataDirPath, file.Name()))
}
}
}
err = os.RemoveAll(oldDefaultWorkPath)

我不喜欢 XDG_CONFIG_HOME,我想使用最早的 ~/.nali 目录,但这段代码删除了整个文件夹,使得 migration 无法完成

@wen-long
Copy link
Author

另外,能否提供一个只读的选项,用来打印存储 config 和 data 的目录
实在找了很久,用 lsof 才找到

@zu1k zu1k closed this as completed in 8aebd93 Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant