tomayac commented on code in PR #19569:
URL: https://github.com/apache/tvm/pull/19569#discussion_r3332835925


##########
web/src/artifact_cache.ts:
##########
@@ -224,13 +226,55 @@ class CrossOriginStorage {
     throw new Error("CrossOriginStorage: Unsupported request type.");
   }
 
+  private async persistHashEntry(
+    url: string,
+    hash: CrossOriginHashDescriptor,
+  ): Promise<void> {
+    try {
+      if (typeof caches === "undefined") {
+        return;
+      }
+      const store = await caches.open(COS_HASH_META_CACHE);
+      await store.put(url, new Response(JSON.stringify(hash)));
+    } catch {
+      // best-effort: ignore storage errors
+    }
+  }
+
+  private async loadPersistedHashEntry(
+    url: string,
+  ): Promise<CrossOriginHashDescriptor | null> {
+    try {
+      if (typeof caches === "undefined") {
+        return null;
+      }
+      const store = await caches.open(COS_HASH_META_CACHE);
+      const response = await store.match(url);
+      if (!response) {
+        return null;
+      }
+      return JSON.parse(await response.text()) as CrossOriginHashDescriptor;
+    } catch {
+      return null;
+    }
+  }
+
   private async resolveHashDescriptor(
     url: string,
   ): Promise<CrossOriginHashDescriptor | null> {
     const cached = this.hashCache.get(url);
     if (cached) {
       return cached;
     }
+    // Check persistent store before falling back to network-based hash 
extraction.
+    // This covers non-LFS files (JSON configs, tokenizers) and 
non-HuggingFace URLs
+    // (e.g. GitHub raw .wasm) whose hashes were computed from blob content on 
a

Review Comment:
   ```suggestion
       // (e.g. GitHub raw .wasm files) whose hashes were computed from blob 
content on a
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to