From 5534bab856dada4624818cc83e5b58a41df0dd90 Mon Sep 17 00:00:00 2001 From: cdez Date: Mon, 21 Apr 2025 19:41:23 -0700 Subject: [PATCH] Attempt number 2? at fixing the logic --- chatserver/server.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chatserver/server.py b/chatserver/server.py index 0cf9ed4..b678d32 100644 --- a/chatserver/server.py +++ b/chatserver/server.py @@ -36,7 +36,15 @@ def handle_client(sock, client_address, socket_list, usernames, chat_rooms, clie client_states[sock] = "NORMAL" user_paths[sock] = None # Initialize path for the user elif state == "NORMAL": - if message.startswith("@") and "-ls" in message: + if message.startswith("SET_PATH"): + # Handle setting the user's directory path + _, path = message.split(" ", 1) + if os.path.isdir(path): + user_paths[sock] = path + sock.send(b"Directory path set successfully.") + else: + sock.send(b"Error: Invalid directory path.") + elif message.startswith("@") and "-ls" in message: # Handle directory listing request parts = message.split() if len(parts) >= 2 and "-ls" in parts[1]: