mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +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
|
||||
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