MCPcopy
hub / github.com/HKUDS/LightRAG / get

Method get

lightrag/parser/markdown/raw_cache.py:121–144  ·  view source on GitHub ↗

Return ``(bytes, fmt)`` for a cached image, or ``None`` on a miss / integrity failure (corrupt or tampered cache file).

(self, url: str)

Source from the content-addressed store, hash-verified

119 self._valid = True
120
121 def get(self, url: str) -> tuple[bytes, str] | None:
122 """Return ``(bytes, fmt)`` for a cached image, or ``None`` on a miss /
123 integrity failure (corrupt or tampered cache file)."""
124 if not self._valid:
125 return None
126 entry = self._index.get(url)
127 if not entry:
128 return None
129 file_name = str(entry.get("file") or "")
130 if not file_name:
131 return None
132 path = self._raw_dir / file_name
133 if not path.is_file():
134 return None
135 try:
136 data = path.read_bytes()
137 except OSError:
138 return None
139 if "sha256:" + hashlib.sha256(data).hexdigest() != entry.get("sha256"):
140 logger.warning("[native_md_cache] cached file integrity mismatch: %s", url)
141 return None
142 fmt = str(entry.get("fmt") or "")
143 self._entries[url] = entry
144 return data, fmt
145
146 def put(self, url: str, data: bytes, fmt: str) -> None:
147 """Store freshly-downloaded image bytes and record them for the manifest."""

Callers 15

resolveNodeColorFunction · 0.45
silentRefreshGuestTokenFunction · 0.45
queryGraphsFunction · 0.45
getGraphLabelsFunction · 0.45
getPopularLabelsFunction · 0.45
searchLabelsFunction · 0.45
checkHealthFunction · 0.45
getDocumentsFunction · 0.45
getDocumentsScanProgressFunction · 0.45
getAuthStatusFunction · 0.45
getPipelineStatusFunction · 0.45
checkEntityNameExistsFunction · 0.45

Calls

no outgoing calls

Tested by 1

storageMockFunction · 0.36