MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / write

Method write

daemon/src/entity/file_writer.ts:99–111  ·  view source on GitHub ↗
(offset: number, chunk: Buffer)

Source from the content-addressed store, hash-verified

97 }
98
99 async write(offset: number, chunk: Buffer) {
100 this.lastUpdate = Date.now();
101 if (offset + chunk.length > this.size) throw new Error("Write exceeds file size limit");
102 if (this.fd === null) throw new Error("File is not opened");
103 await fs.write(this.fd, chunk, 0, chunk.length, offset);
104
105 this.addWrittenRange(offset, offset + chunk.length);
106 if (this.isFullyCovered()) {
107 this.done().catch((e) => {
108 logger.error("Error completing file upload:", e);
109 }); // async
110 }
111 }
112
113 async done() {
114 if (this.fd != null) {

Callers 3

Instance_router.tsFile · 0.45
stream_router.tsFile · 0.45
http_router.tsFile · 0.45

Calls 4

addWrittenRangeMethod · 0.95
isFullyCoveredMethod · 0.95
doneMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected