(offset: number, chunk: Buffer)
| 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) { |
no test coverage detected