From d6d42ebe81b8d90c0a109c99e8d072ae1aca0f9a Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 7 Jan 2024 18:57:03 -0500 Subject: [PATCH] Fixed small startup bug --- pubnix.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pubnix.py b/pubnix.py index ae673f1..10e3528 100644 --- a/pubnix.py +++ b/pubnix.py @@ -30,6 +30,8 @@ MESSAGE_BUFFER_LEN = 1024 TOKEN_LENGTH = 50 TIMEOUT = 5 * 60 # 5 minutes +SERVER_FOLDER = Path(__file__).parent.absolute() + ### # Server ### @@ -98,8 +100,9 @@ def start_server(address, allow_other=True): if allow_other: # 33279 = '-rwxrwxrwx.' - os.chmod("game.sock", 33279) - os.chmod("challenges", 33279) + os.chmod(f"{SERVER_FOLDER}/game.sock", 33279) + if os.path.exists(f"{SERVER_FOLDER}/challenges"): + os.chmod(f"{SERVER_FOLDER}/challenges", 33279) try: yield sock @@ -108,7 +111,6 @@ def start_server(address, allow_other=True): os.unlink(address) def generate_challenge(user): - SERVER_FOLDER = Path(__file__).parent.absolute() Path(f"{SERVER_FOLDER}/challenges").mkdir(mode=33279, exist_ok=True) return ChallengeMessage( username=user,