Autodownload optional pattern check to separate function to allow plugins
This commit is contained in:
parent
d1ad7e0850
commit
83b3dc8fbe
2 changed files with 9 additions and 5 deletions
|
@ -96,9 +96,9 @@ class ContentManager(object):
|
|||
if old_content and old_content.get("files_optional", {}).get(relative_path):
|
||||
# We have the file in the old content
|
||||
old_hash = old_content["files_optional"][relative_path].get("sha512")
|
||||
if old_hash != new_hash and self.site.settings.get("autodownloadoptional"):
|
||||
changed.append(content_inner_dir + relative_path) # Download new file
|
||||
elif old_hash != new_hash and not self.site.settings.get("own"):
|
||||
if old_hash != new_hash and self.site.isDownloadable(file_inner_path):
|
||||
changed.append(file_inner_path) # Download new file
|
||||
elif old_hash != new_hash and self.hashfield.hasHash(old_hash) and not self.site.settings.get("own"):
|
||||
try:
|
||||
self.optionalRemove(file_inner_path, old_hash, old_content["files_optional"][relative_path]["size"])
|
||||
self.site.storage.delete(file_inner_path)
|
||||
|
@ -106,8 +106,8 @@ class ContentManager(object):
|
|||
except Exception, err:
|
||||
self.log.debug("Error deleting file %s: %s" % (file_inner_path, err))
|
||||
else: # The file is not in the old content
|
||||
if self.site.settings.get("autodownloadoptional"):
|
||||
changed.append(content_inner_dir + relative_path) # Download new file
|
||||
if self.site.isDownloadable(file_inner_path):
|
||||
changed.append(file_inner_path) # Download new file
|
||||
|
||||
# Check deleted
|
||||
if old_content:
|
||||
|
|
|
@ -939,6 +939,10 @@ class Site(object):
|
|||
self.log.debug("Queried hashfield from %s peers" % queried)
|
||||
return queried
|
||||
|
||||
# Returns if the optional file is need to be downloaded or not
|
||||
def isDownloadable(self, inner_path):
|
||||
return self.settings.get("autodownloadoptional")
|
||||
|
||||
def delete(self):
|
||||
self.settings["serving"] = False
|
||||
self.saveSettings()
|
||||
|
|
Loading…
Reference in a new issue