From 013843e4e80cc5ac26f5be203bce5e0fd8b390df Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Fri, 22 Nov 2019 17:15:20 +0000 Subject: [PATCH] Move creation files into the proper function --- nethack-launcher/create_user_files.go | 9 +++++++++ nethack-launcher/print_register_screen.go | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nethack-launcher/create_user_files.go b/nethack-launcher/create_user_files.go index c0920b6..5772ae9 100644 --- a/nethack-launcher/create_user_files.go +++ b/nethack-launcher/create_user_files.go @@ -7,6 +7,15 @@ import ( ) func createUserFiles(username string) { + // create user directories + userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username) + exec.Command("mkdir", "-p", userPath).Run() + + // copy in rc file + 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() + // create necessary directories if they dont exist userpath := fmt.Sprintf("%s/user/%s", config.NethackLauncher.HackDir, username) diff --git a/nethack-launcher/print_register_screen.go b/nethack-launcher/print_register_screen.go index 5b527c9..323bfb4 100644 --- a/nethack-launcher/print_register_screen.go +++ b/nethack-launcher/print_register_screen.go @@ -72,16 +72,7 @@ func printRegisterScreen(redisClient *redis.Client) { secHash := sha3.Sum512([]byte(sec)) redisClient.Set(fmt.Sprintf("user:%s", username), fmt.Sprintf("%x", secHash), 0).Err() - // create user directories - userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username) - exec.Command("mkdir", "-p", userPath).Run() - - // copy in rc file - 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() - - // TODO: move the above creation code into the createUserFiles() function + // stage user directory and files createUserFiles(username) // back to main screen