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

Method getDbFiles

src/Site/SiteStorage.py:99–120  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97
98 # Return possible db files for the site
99 def getDbFiles(self):
100 found = 0
101 for content_inner_path, content in self.site.content_manager.contents.items():
102 # content.json file itself
103 if self.isFile(content_inner_path):
104 yield content_inner_path, self.getPath(content_inner_path)
105 else:
106 self.log.error("[MISSING] %s" % content_inner_path)
107 # Data files in content.json
108 content_inner_path_dir = helper.getDirname(content_inner_path) # Content.json dir relative to site
109 for file_relative_path in list(content.get("files", {}).keys()) + list(content.get("files_optional", {}).keys()):
110 if not file_relative_path.endswith(".json") and not file_relative_path.endswith("json.gz"):
111 continue # We only interesed in json files
112 file_inner_path = content_inner_path_dir + file_relative_path # File Relative to site dir
113 file_inner_path = file_inner_path.strip("/") # Strip leading /
114 if self.isFile(file_inner_path):
115 yield file_inner_path, self.getPath(file_inner_path)
116 else:
117 self.log.error("[MISSING] %s" % file_inner_path)
118 found += 1
119 if found % 100 == 0:
120 time.sleep(0.001) # Context switch to avoid UI block
121
122 # Rebuild sql cache
123 @util.Noparallel()

Callers 1

rebuildDbMethod · 0.95

Calls 5

isFileMethod · 0.95
getPathMethod · 0.95
itemsMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected