From 6947f2c03c219e4be437a8ff427fb584a0b1ed03 Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Sat, 24 Jun 2023 12:44:17 +0300 Subject: [PATCH] Exit gracefully if the transfer directory already exists --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0122f5a..c18f04b 100644 --- a/main.go +++ b/main.go @@ -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) } }