Skip to content

Commit

Permalink
Mark my optional files using directory on signing instead of file path
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Oct 4, 2017
1 parent cd02531 commit e8a439c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/OptionalManager/ContentDbPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def setContentFilesOptional(self, site, content_inner_path, content, cur=None):
is_downloaded = 1
else:
is_downloaded = 0
if site.address + "/" + file_inner_path in self.my_optional_files:
if site.address + "/" + content_inner_dir in self.my_optional_files:
is_pinned = 1
else:
is_pinned = 0
Expand Down
9 changes: 5 additions & 4 deletions plugins/OptionalManager/UiWebsocketPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ def __init__(self, *args, **kwargs):
self.time_peer_numbers_updated = 0
super(UiWebsocketPlugin, self).__init__(*args, **kwargs)

def actionFileWrite(self, to, inner_path, *args, **kwargs):
super(UiWebsocketPlugin, self).actionFileWrite(to, inner_path, *args, **kwargs)

def actionSiteSign(self, to, privatekey=None, inner_path="content.json", *args, **kwargs):
# Add file to content.db and set it as pinned
content_db = self.site.content_manager.contents.db
content_db.my_optional_files[self.site.address + "/" + inner_path] = time.time()
content_inner_dir = helper.getDirname(inner_path)
content_db.my_optional_files[self.site.address + "/" + content_inner_dir] = time.time()
if len(content_db.my_optional_files) > 50: # Keep only last 50
oldest_key = min(
content_db.my_optional_files.iterkeys(),
key=(lambda key: content_db.my_optional_files[key])
)
del content_db.my_optional_files[oldest_key]

return super(UiWebsocketPlugin, self).actionSiteSign(to, privatekey, inner_path, *args, **kwargs)

def updatePeerNumbers(self):
content_db = self.site.content_manager.contents.db
content_db.updatePeerNumbers()
Expand Down

0 comments on commit e8a439c

Please sign in to comment.