From bd8fd497c12510d020be903ff23f21f7d04cfd8f Mon Sep 17 00:00:00 2001 From: mfaltys Date: Fri, 4 Nov 2022 09:56:05 -0500 Subject: [PATCH] Do not overwrite user config on login --- nethack-launcher/create_user_files.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nethack-launcher/create_user_files.go b/nethack-launcher/create_user_files.go index 2248851..9296a65 100644 --- a/nethack-launcher/create_user_files.go +++ b/nethack-launcher/create_user_files.go @@ -11,10 +11,12 @@ func createUserFiles(username string) { userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username) exec.Command("mkdir", "-p", userPath).Run() - // copy in rc file + // copy in rc file if it does not exist hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir) - hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) - exec.Command("cp", hackRCLoc, hackRCDest).Run() + if _, err := os.Stat(hackRCLoc); os.IsNotExist(err) { + hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) + exec.Command("cp", hackRCLoc, hackRCDest).Run() + } // create necessary directories if they dont exist userpath := fmt.Sprintf("%s/user/%s", config.NethackLauncher.HackDir, username)