Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Aug 19, 2024
1 parent 3b20fed commit e7fe626
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/cache-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CacheManager {
stream: ReadableStream,
metadata: CacheEntryMetadata
): Promise<void> {
this._writeMetadata(name, metadata); // no need await
this.writeMetadata(name, metadata); // no need await
return await opfsWrite(name, stream);
}

Expand Down Expand Up @@ -184,9 +184,11 @@ class CacheManager {
}

/**
* Internally used
* Write the metadata of the file to disk.
*
* This function is separated from `write()` for compatibility reason. In older version of wllama, there was no metadata for cached file, so when newer version of wllama loads a file created by older version, it will try to polyfill the metadata.
*/
private async _writeMetadata(
async writeMetadata(
name: string,
metadata: CacheEntryMetadata
): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/downloader/remote-blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class GGUFRemoteBlob extends Blob {
// migrate from old version: if metadata is polyfilled, we save the new metadata
const metadataPolyfilled = cachedFile?.etag === POLYFILL_ETAG;
if (metadataPolyfilled) {
await cacheManager._writeMetadata(cacheKey, remoteFile);
await cacheManager.writeMetadata(cacheKey, remoteFile);
}

const cachedFileValid =
Expand Down

0 comments on commit e7fe626

Please sign in to comment.