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

Method init

daemon/src/entity/file_writer.ts:79–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77 }
78
79 async init() {
80 if (this.fd != null) return;
81 let locked = false;
82 try {
83 if (lockfile.checkSync(this.path)) locked = true;
84 } catch {}
85 if (locked) {
86 throw new Error("File is locked");
87 }
88 try {
89 this.fd = await fs.open(this.path, "w+");
90 this.releaseLock = await lockfile.lock(this.path);
91 await fs.ftruncate(this.fd, this.size);
92 } catch (e) {
93 if (typeof this.releaseLock === "function") await this.releaseLock();
94 this.releaseLock = undefined;
95 throw e;
96 }
97 }
98
99 async write(offset: number, chunk: Buffer) {
100 this.lastUpdate = Date.now();

Callers 3

index.tsFile · 0.45
index.tsFile · 0.45
http_router.tsFile · 0.45

Calls 1

openMethod · 0.80

Tested by

no test coverage detected