packages/reflex-cache: pass content to ipfs_fetch_task directly if possible
This commit is contained in:
parent
089e570054
commit
4f9e72af6c
2 changed files with 8 additions and 5 deletions
|
@ -13,9 +13,12 @@ class IPFSController:
|
|||
self.__nix = nixCache
|
||||
self.__db = db
|
||||
|
||||
def ipfs_fetch_task(self, callback, nar, hint=None):
|
||||
def ipfs_fetch_task(self, callback, nar, hint=None, content=None):
|
||||
if content == None:
|
||||
print(f"Downloading NAR: {nar}")
|
||||
code, _, content = self.__nix.try_all("get", nar, hint)
|
||||
else:
|
||||
code = 200
|
||||
if code == 200:
|
||||
if nar.endswith(".nar.xz"):
|
||||
print(f"Attempt decompression of {nar}")
|
||||
|
|
|
@ -49,7 +49,7 @@ class ReflexHTTPServiceHandler(BaseHTTPRequestHandler):
|
|||
resultHash = self._db.get_path(self.path)
|
||||
|
||||
if resultHash == None:
|
||||
code, cache, _ = self._nix.try_all("get", self.path)
|
||||
code, cache, content = self._nix.try_all("get", self.path)
|
||||
if code != 200:
|
||||
self.send_response(404)
|
||||
self.end_headers()
|
||||
|
@ -75,7 +75,7 @@ class ReflexHTTPServiceHandler(BaseHTTPRequestHandler):
|
|||
# already removed
|
||||
pass
|
||||
f = self._executor_nar.submit(
|
||||
self._ipfs.ipfs_fetch_task, cb, self.path, cache
|
||||
self._ipfs.ipfs_fetch_task, cb, self.path, cache, content
|
||||
)
|
||||
self._workSet.add((self.path, f))
|
||||
_, code, resultHash = f.result()
|
||||
|
|
Loading…
Reference in a new issue