Don't remove missing optional files

This commit is contained in:
shortcutme 2017-01-27 12:02:14 +01:00
parent 0f0cf18f92
commit 697e177e13
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
4 changed files with 18 additions and 5 deletions

View file

@ -491,7 +491,7 @@ class ContentManager(object):
# Create and sign a content.json
# Return: The new content if filewrite = False
def sign(self, inner_path="content.json", privatekey=None, filewrite=True, update_changed_files=False, extend=None):
def sign(self, inner_path="content.json", privatekey=None, filewrite=True, update_changed_files=False, extend=None, remove_missing_optional=False):
if inner_path in self.contents:
content = self.contents[inner_path]
if self.contents[inner_path].get("cert_sign", False) is None and self.site.storage.isFile(inner_path):
@ -523,6 +523,11 @@ class ContentManager(object):
helper.getDirname(inner_path), content.get("ignore"), content.get("optional")
)
if not remove_missing_optional:
for file_inner_path, file_details in content.get("files_optional", {}).iteritems():
if file_inner_path not in files_optional_node:
files_optional_node[file_inner_path] = file_details
# Find changed files
files_merged = files_node.copy()
files_merged.update(files_optional_node)