MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / loadContents

Method loadContents

src/Content/ContentManager.py:41–55  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

39
40 # Load all content.json files
41 def loadContents(self):
42 if len(self.contents) == 0:
43 self.log.debug("ContentDb not initialized, load files from filesystem")
44 self.loadContent(add_bad_files=False, delete_removed_files=False)
45 self.site.settings["size"], self.site.settings["size_optional"] = self.getTotalSize()
46
47 # Load hashfield cache
48 if "hashfield" in self.site.settings.get("cache", {}):
49 self.hashfield.frombytes(base64.b64decode(self.site.settings["cache"]["hashfield"]))
50 del self.site.settings["cache"]["hashfield"]
51 elif self.contents.get("content.json") and self.site.settings["size_optional"] > 0:
52 self.site.storage.updateBadFiles() # No hashfield cache created yet
53 self.has_optional_files = bool(self.hashfield)
54
55 self.contents.db.initSite(self.site)
56
57 def getFileChanges(self, old_files, new_files):
58 deleted = {key: val for key, val in old_files.items() if key not in new_files}

Callers 1

__init__Method · 0.80

Calls 6

loadContentMethod · 0.95
getTotalSizeMethod · 0.95
updateBadFilesMethod · 0.80
getMethod · 0.45
frombytesMethod · 0.45
initSiteMethod · 0.45

Tested by

no test coverage detected