Remove missing optional files from content.json on cloning

This commit is contained in:
shortcutme 2018-11-07 22:48:35 +01:00
parent eae6a34bfc
commit cf7d194dbf
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
2 changed files with 6 additions and 2 deletions

View File

@ -681,13 +681,13 @@ class Site(object):
delete_removed_files=False, load_includes=False
)
if privatekey:
new_site.content_manager.sign(file_inner_path.replace("-default", ""), privatekey)
new_site.content_manager.sign(file_inner_path.replace("-default", ""), privatekey, remove_missing_optional=True)
new_site.content_manager.loadContent(
file_inner_path, add_bad_files=False, delete_removed_files=False, load_includes=False
)
if privatekey:
new_site.content_manager.sign("content.json", privatekey)
new_site.content_manager.sign("content.json", privatekey, remove_missing_optional=True)
new_site.content_manager.loadContent(
"content.json", add_bad_files=False, delete_removed_files=False, load_includes=False
)

View File

@ -29,6 +29,10 @@ class TestSite:
assert new_site.storage.verifyFiles()["bad_files"] == [] # No bad files allowed
assert new_site.storage.query("SELECT * FROM keyvalue WHERE key = 'title'").fetchone()["value"] == "MyZeroBlog"
# Optional files should be removed
assert len(new_site.storage.loadJson("content.json").get("files_optional", {})) == 0
# Test re-cloning (updating)
# Changes in non-data files should be overwritten