mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 14:42:28 +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
|
||||
script = new Script(fn, data, server.hostname, server.scripts);
|
||||
server.scripts.push(script);
|
||||
return true;
|
||||
return script.updateRamUsage(server.scripts);
|
||||
}
|
||||
mode === "w" ? (script.code = data) : (script.code += data);
|
||||
script.updateRamUsage(server.scripts);
|
||||
script.markUpdated();
|
||||
return script.updateRamUsage(server.scripts);
|
||||
} else {
|
||||
// Write to text file
|
||||
const txtFile = getTextFile(fn, server);
|
||||
if (txtFile == null) {
|
||||
createTextFile(fn, data, server);
|
||||
return true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (mode === "w") {
|
||||
txtFile.write(data);
|
||||
@ -2339,7 +2338,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
txtFile.append(data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
throw makeRuntimeErrorMsg("write", `Invalid argument: ${port}`);
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ export class Script {
|
||||
if (res > 0) {
|
||||
this.ramUsage = roundToTwo(res);
|
||||
}
|
||||
this.markUpdated();
|
||||
}
|
||||
|
||||
// Serialize the current object to a JSON save state
|
||||
|
Loading…
Reference in New Issue
Block a user