mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-11 02:03:58 +01:00
Merge pull request #1444 from danielyxie/dev
write can be awaited in order to wait for the ram calculation to go t…
This commit is contained in:
commit
09e1ee8f6d
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