Skip to content

Commit

Permalink
Fix #1029
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiascode committed Mar 20, 2021
1 parent 0239630 commit 08a6b22
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
17 changes: 15 additions & 2 deletions pynicotine/pynicotine.py
Expand Up @@ -1994,6 +1994,10 @@ def send_have_no_parent(self):
us a PossibleParents message, or start sending us search requests. """

self.has_parent = False
self.queue.put(slskmessages.AcceptChildren(0))

# TODO: allow child connections
self.queue.put(slskmessages.ChildDepth(0))

self.queue.put(slskmessages.HaveNoParent(1))
self.queue.put(slskmessages.BranchRoot(self.config.sections["server"]["login"]))
Expand Down Expand Up @@ -2033,16 +2037,25 @@ def distrib_branch_level(self, msg):
else:
self.send_have_no_parent()

else:
# Our parent sent an update
self.queue.put(slskmessages.BranchLevel(msg.value + 1))

def distrib_branch_root(self, msg):
""" Distrib code: 5 """

log.add_msg_contents(msg)

# Inform the server of our branch root
self.queue.put(slskmessages.BranchRoot(msg.user))
if msg.conn == self.get_parent_conn().conn:
print("HM")
self.queue.put(slskmessages.BranchRoot(msg.user))

def distrib_child_depth(self, msg):
""" Distrib code: 7 """

# TODO: Implement me
log.add_msg_contents(msg)

# TODO: allow child connections
if msg.conn != self.get_parent_conn().conn:
self.queue.put(slskmessages.ChildDepth(0))
5 changes: 4 additions & 1 deletion pynicotine/search.py
Expand Up @@ -200,11 +200,14 @@ def process_search_request(self, searchterm, user, searchid, direct=False):
several times a second, please keep it as optimized and memory
sparse as possible! """

if searchterm is None:
return

if not self.config.sections["searches"]["search_results"]:
# Don't return _any_ results when this option is disabled
return

if searchterm is None:
if self.np.shares.rescanning:
return

if not direct and user == self.config.sections["server"]["login"]:
Expand Down
4 changes: 4 additions & 0 deletions pynicotine/shares.py
Expand Up @@ -493,6 +493,7 @@ def __init__(self, np, config, queue, ui_callback=None, connected=False):
self.connected = connected
self.translatepunctuation = str.maketrans(dict.fromkeys(string.punctuation, ' '))
self.share_dbs = {}
self.rescanning = False

self.convert_shares()
self.public_share_dbs = [
Expand Down Expand Up @@ -837,6 +838,7 @@ def process_scanner_messages(self, sharestype, scanner, scanner_queue):

def rescan_shares(self, sharestype, rebuild=False, thread=True):

self.rescanning = True
shared_folders = self.get_shared_folders(sharestype)

# Hand over database control to the scanner process
Expand Down Expand Up @@ -882,3 +884,5 @@ def _process_scanner(self, scanner, scanner_queue, sharestype):

if self.ui_callback:
self.ui_callback.rescan_finished(sharestype)

self.rescanning = False
4 changes: 4 additions & 0 deletions pynicotine/transfers.py
Expand Up @@ -2052,6 +2052,9 @@ def get_queued_uploads(self):
elif not use_privileged_queue:
list_queued.append(i)

log.add_transfer("Privileged upload queue: %s", str(list_privileged))
log.add_transfer("Regular upload queue: %s", str(list_queued))

if use_privileged_queue:
# Upload to a privileged user
# Only Privileged users' files will get selected
Expand Down Expand Up @@ -2081,6 +2084,7 @@ def get_upload_candidate(self, queued_uploads):
# Break loop
mintimequeued = i.timequeued

log.add_transfer("Upload candidate: %s", upload_candidate)
return upload_candidate

# Find next file to upload
Expand Down

0 comments on commit 08a6b22

Please sign in to comment.