Attempt number 2? at fixing the logic
This commit is contained in:
parent
fe4aa750fe
commit
5534bab856
1 changed files with 9 additions and 1 deletions
|
|
@ -36,7 +36,15 @@ def handle_client(sock, client_address, socket_list, usernames, chat_rooms, clie
|
||||||
client_states[sock] = "NORMAL"
|
client_states[sock] = "NORMAL"
|
||||||
user_paths[sock] = None # Initialize path for the user
|
user_paths[sock] = None # Initialize path for the user
|
||||||
elif state == "NORMAL":
|
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
|
# Handle directory listing request
|
||||||
parts = message.split()
|
parts = message.split()
|
||||||
if len(parts) >= 2 and "-ls" in parts[1]:
|
if len(parts) >= 2 and "-ls" in parts[1]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue