MCPcopy Create free account
hub / github.com/apache/tvm / write

Method write

web/src/opfs_store.ts:164–191  ·  view source on GitHub ↗
(url: string, response: Response)

Source from the content-addressed store, hash-verified

162 }
163
164 async write(url: string, response: Response): Promise<void> {
165 try {
166 const directory = await this.getScopedDirectory();
167 const baseName = await this.hashUrl(url);
168 await this.removeEntryIfExists(
169 directory,
170 this.getRecordFilename(baseName),
171 );
172 const payloadHandle = await directory.getFileHandle(
173 this.getPayloadFilename(baseName),
174 { create: true },
175 );
176 const nbytes = await this.writePayload(payloadHandle, response);
177 const recordHandle = await directory.getFileHandle(
178 this.getRecordFilename(baseName),
179 { create: true },
180 );
181 const record: OPFSStoreRecord = {
182 url,
183 nbytes,
184 contentType: response.headers.get("content-type") ?? undefined,
185 };
186 await this.writeRecord(recordHandle, record);
187 } catch (err) {
188 this.resetDirectoryOnInvalidStateError(err);
189 throw err;
190 }
191 }
192
193 async remove(url: string): Promise<void> {
194 try {

Callers

nothing calls this directly

Calls 10

getScopedDirectoryMethod · 0.95
hashUrlMethod · 0.95
removeEntryIfExistsMethod · 0.95
getRecordFilenameMethod · 0.95
getPayloadFilenameMethod · 0.95
writePayloadMethod · 0.95
writeRecordMethod · 0.95
getFileHandleMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected