Skip to content

Commit 54b7999

Browse files
committed
users.py: remove workaround for old server bug
This bug should be fixed in the official server now.
1 parent c5f9823 commit 54b7999

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

pynicotine/users.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def __init__(self, username):
5353
class Users:
5454
__slots__ = ("login_status", "login_username", "public_ip_address", "public_port",
5555
"server_hostname", "server_port", "privileges_left", "_should_open_privileges_url",
56-
"addresses", "countries", "statuses", "watched", "privileged", "_ip_requested",
57-
"_pending_watch_removals")
56+
"addresses", "countries", "statuses", "watched", "privileged", "_ip_requested")
5857
USERNAME_MAX_LENGTH = 30
5958

6059
def __init__(self):
@@ -74,7 +73,6 @@ def __init__(self):
7473
self.watched = {}
7574
self.privileged = set()
7675
self._ip_requested = {}
77-
self._pending_watch_removals = set()
7876

7977
for event_name, callback in (
8078
("admin-message", self._admin_message),
@@ -226,7 +224,6 @@ def _server_disconnect(self, msg):
226224
self.watched.clear()
227225
self.privileged.clear()
228226
self._ip_requested.clear()
229-
self._pending_watch_removals.clear()
230227

231228
self.login_username = None
232229
self.public_ip_address = None
@@ -323,12 +320,8 @@ def _watch_user(self, msg):
323320
"""Server code 5."""
324321

325322
if not msg.userexists:
326-
# User does not exist. The server will not keep us informed if the user is created
327-
# later, so we need to remove the user from our list.
328-
# Due to a bug, the server will in rare cases tell us a user doesn't exist, while
329-
# the user is actually online. Remove the user when we receive a UserStatus message
330-
# telling us the user is offline.
331-
self._pending_watch_removals.add(msg.user)
323+
log.add_conn("Unwatching non-existent user %s", msg.user)
324+
self.watched.pop(msg.user, None)
332325
return
333326

334327
if msg.contains_stats:
@@ -365,11 +358,6 @@ def _user_status(self, msg):
365358
self.addresses.pop(username, None)
366359
self.countries.pop(username, None)
367360

368-
if username in self._pending_watch_removals:
369-
# User does not exist, remove it from list
370-
log.add_conn("Unwatching non-existent user %s", username)
371-
self.watched.pop(username, None)
372-
373361
elif is_watched:
374362
user_status = self.statuses.get(username)
375363

@@ -385,7 +373,6 @@ def _user_status(self, msg):
385373
if is_watched:
386374
self.statuses[username] = status
387375

388-
self._pending_watch_removals.discard(username)
389376
core.pluginhandler.user_status_notification(username, status, msg.privileged)
390377

391378
def _connect_to_peer(self, msg):

0 commit comments

Comments
 (0)