Exit gracefully if the transfer directory already exists

This commit is contained in:
FIGBERT 2023-06-24 12:44:17 +03:00
parent 89dd9f9a6a
commit 6947f2c03c
No known key found for this signature in database
GPG key ID: 67F1598D607A844B

10
main.go
View file

@ -61,7 +61,15 @@ func main() {
}
if *logInForTransfer {
if currentDir, err := os.Getwd(); err == nil {
os.Setenv("GOMUKS_ROOT", filepath.Join(currentDir, "transfer"))
pack := filepath.Join(currentDir, "transfer")
if _, err := os.Stat(pack); err == nil {
fmt.Println("with the --log-in-for-transfer flag, gomuks packs your data up into")
fmt.Println("the transfer/ directory so you can move it around easily. please make")
fmt.Println("sure there is nothing there already, and then run it again.")
os.Exit(1)
}
os.Setenv("GOMUKS_ROOT", pack)
}
}