Skip to content

Commit

Permalink
Rev1416, Remove merger permission from merged sites
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Aug 15, 2016
1 parent e9009c5 commit 8cd7a63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions plugins/MergerSite/MergerSitePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def fileDone(self, inner_path):
virtual_path = "merged-%s/%s/%s" % (merged_type, self.address, inner_path)

for merger_site in merged_to_merger.get(self.address, []):
if merger_site.address == self.address:
continue
merger_site.fileDone(virtual_path)

def fileFailed(self, inner_path):
Expand All @@ -254,6 +256,8 @@ def fileFailed(self, inner_path):
virtual_path = "merged-%s/%s/%s" % (merged_type, self.address, inner_path)

for merger_site in merged_to_merger.get(self.address, []):
if merger_site.address == self.address:
continue
merger_site.fileFailed(virtual_path)


Expand All @@ -268,21 +272,25 @@ def updateMergerSites(self):
merged_to_merger = {}
site_manager = self
for site in self.sites.itervalues():
# Update merged sites
merged_type = site.content_manager.contents.get("content.json", {}).get("merged_type")
if merged_type:
merged_db[site.address] = merged_type

# Update merger sites
for permission in site.settings["permissions"]:
if not permission.startswith("Merger:"):
continue
if merged_type:
self.log.error("Removing permission %s from %s: Merger and merged at the same time." % (permission, site.address))
site.settings["permissions"].remove(permission)
continue
merger_type = permission.replace("Merger:", "")
if site.address not in merger_db:
merger_db[site.address] = []
merger_db[site.address].append(merger_type)
site_manager.sites[site.address] = site

# Update merged sites
merged_type = site.content_manager.contents.get("content.json", {}).get("merged_type")
if merged_type:
merged_db[site.address] = merged_type

# Update merged to merger
if merged_type:
for merger_site in self.sites.itervalues():
Expand All @@ -292,7 +300,6 @@ def updateMergerSites(self):
merged_to_merger[site.address].append(merger_site)
self.log.debug("Updated merger sites in %.3fs" % (time.time() - s))


def load(self, *args, **kwags):
super(SiteManagerPlugin, self).load(*args, **kwags)
self.updateMergerSites()
Expand Down
2 changes: 1 addition & 1 deletion src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Config(object):

def __init__(self, argv):
self.version = "0.4.0"
self.rev = 1413
self.rev = 1416
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"
Expand Down

0 comments on commit 8cd7a63

Please sign in to comment.