mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 16:13:49 +01:00
write can be awaited in order to wait for the ram calculation to go through
This commit is contained in:
parent
e91c183d37
commit
8e4722c5e7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2321,17 +2321,16 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
// Create a new script
|
// Create a new script
|
||||||
script = new Script(fn, data, server.hostname, server.scripts);
|
script = new Script(fn, data, server.hostname, server.scripts);
|
||||||
server.scripts.push(script);
|
server.scripts.push(script);
|
||||||
return true;
|
return script.updateRamUsage(server.scripts);
|
||||||
}
|
}
|
||||||
mode === "w" ? (script.code = data) : (script.code += data);
|
mode === "w" ? (script.code = data) : (script.code += data);
|
||||||
script.updateRamUsage(server.scripts);
|
return script.updateRamUsage(server.scripts);
|
||||||
script.markUpdated();
|
|
||||||
} else {
|
} else {
|
||||||
// Write to text file
|
// Write to text file
|
||||||
const txtFile = getTextFile(fn, server);
|
const txtFile = getTextFile(fn, server);
|
||||||
if (txtFile == null) {
|
if (txtFile == null) {
|
||||||
createTextFile(fn, data, server);
|
createTextFile(fn, data, server);
|
||||||
return true;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
if (mode === "w") {
|
if (mode === "w") {
|
||||||
txtFile.write(data);
|
txtFile.write(data);
|
||||||
@ -2339,7 +2338,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
txtFile.append(data);
|
txtFile.append(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
throw makeRuntimeErrorMsg("write", `Invalid argument: ${port}`);
|
throw makeRuntimeErrorMsg("write", `Invalid argument: ${port}`);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ export class Script {
|
|||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
this.ramUsage = roundToTwo(res);
|
this.ramUsage = roundToTwo(res);
|
||||||
}
|
}
|
||||||
|
this.markUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize the current object to a JSON save state
|
// Serialize the current object to a JSON save state
|
||||||
|
Loading…
Reference in New Issue
Block a user