Attempt number 2? at fixing the logic

This commit is contained in:
Charles Descamps 2025-04-21 19:41:23 -07:00
parent fe4aa750fe
commit 5534bab856

View file

@ -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]: