MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / __init__

Method __init__

src/Content/ContentDb.py:12–37  ·  view source on GitHub ↗
(self, path)

Source from the content-addressed store, hash-verified

10@PluginManager.acceptPlugins
11class ContentDb(Db):
12 def __init__(self, path):
13 Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path)
14 self.foreign_keys = True
15 try:
16 self.schema = self.getSchema()
17 try:
18 self.checkTables()
19 except DbTableError:
20 pass
21 self.log.debug("Checking foreign keys...")
22 foreign_key_error = self.execute("PRAGMA foreign_key_check").fetchone()
23 if foreign_key_error:
24 raise Exception("Database foreign key error: %s" % foreign_key_error)
25 except Exception as err:
26 self.log.error("Error loading content.db: %s, rebuilding..." % Debug.formatException(err))
27 self.close()
28 os.unlink(path) # Remove and try again
29 Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path)
30 self.foreign_keys = True
31 self.schema = self.getSchema()
32 try:
33 self.checkTables()
34 except DbTableError:
35 pass
36 self.site_ids = {}
37 self.sites = {}
38
39 def getSchema(self):
40 schema = {}

Callers

nothing calls this directly

Calls 5

getSchemaMethod · 0.95
errorMethod · 0.80
checkTablesMethod · 0.45
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected