internal/osutil: move the config dir to perkeep

Updates #981

Change-Id: I71ceea6395d31851e8502a2f397acb22056fe1b0
This commit is contained in:
Brad Fitzpatrick 2018-04-21 12:50:24 -07:00
parent 86ee09b012
commit 9ce352249c
1 changed files with 20 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package osutil
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
@ -127,6 +128,25 @@ func CamliConfigDir() string {
}
func camliConfigDir() string {
if fi, err := os.Lstat(oldCamliConfigDir()); err == nil && fi.IsDir() {
fmt.Fprintf(os.Stderr, "Error: old configuration directory detected. Not running until it's moved.\nRename %s to %s\n",
oldCamliConfigDir(), perkeepConfigDir())
os.Exit(1)
}
return perkeepConfigDir()
}
func perkeepConfigDir() string {
if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "Perkeep")
}
if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" {
return filepath.Join(xdg, "perkeep")
}
return filepath.Join(HomeDir(), ".config", "perkeep")
}
func oldCamliConfigDir() string {
if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "Camlistore")
}