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

Method loadItem

src/Content/ContentDbDict.py:21–39  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

19 self.log.debug("ContentDb init: %.3fs, found files: %s, sites: %s" % (time.time() - s, len(self), len(self.db.site_ids)))
20
21 def loadItem(self, key):
22 try:
23 self.num_loaded += 1
24 if self.num_loaded % 100 == 0:
25 if config.verbose:
26 self.log.debug("Loaded json: %s (latest: %s) called by: %s" % (self.num_loaded, key, Debug.formatStack()))
27 else:
28 self.log.debug("Loaded json: %s (latest: %s)" % (self.num_loaded, key))
29 content = self.site.storage.loadJson(key)
30 dict.__setitem__(self, key, content)
31 except IOError:
32 if dict.get(self, key):
33 self.__delitem__(key) # File not exists anymore
34 raise KeyError(key)
35
36 self.addCachedKey(key)
37 self.checkLimit()
38
39 return content
40
41 def getItemSize(self, key):
42 return self.site.storage.getSize(key)

Callers 3

__getitem__Method · 0.95
valuesMethod · 0.95
actionBigfileUploadMethod · 0.80

Calls 6

__delitem__Method · 0.95
addCachedKeyMethod · 0.95
checkLimitMethod · 0.95
loadJsonMethod · 0.80
__setitem__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected