synchronize scp and write

This commit is contained in:
Snarling 2022-08-17 18:55:12 -04:00
parent 95a1c18139
commit f6a8d5d337
3 changed files with 4 additions and 3 deletions

@ -839,7 +839,8 @@ const base: InternalAPI<NS> = {
throw helpers.makeRuntimeErrorMsg(ctx, "No scripts to copy");
}
let res = true;
scripts.map(function (script) {
scripts.forEach(function (script) {
//TODO: This array method still needs to be reworked because it is terribly inefficient.
if (!NetscriptFunctions(ctx.workerScript).scp(script, destination, source)) {
res = false;
}

@ -29,7 +29,7 @@ export async function compile(player: IPlayer, script: Script, scripts: Script[]
// but not really behaves like import. Particularly, it cannot
// load fully dynamic content. So we hide the import from webpack
// by placing it inside an eval call.
await script.updateRamUsage(player, scripts);
script.updateRamUsage(player, scripts);
const uurls = _getScriptUrls(script, scripts, []);
const url = uurls[uurls.length - 1].url;
if (script.url && script.url !== url) {

@ -277,7 +277,7 @@ export function Root(props: IProps): React.ReactElement {
}
setUpdatingRam(true);
const codeCopy = newCode + "";
const ramUsage = await calculateRamUsage(props.player, codeCopy, props.player.getCurrentServer().scripts);
const ramUsage = calculateRamUsage(props.player, codeCopy, props.player.getCurrentServer().scripts);
if (ramUsage.cost > 0) {
const entries = ramUsage.entries?.sort((a, b) => b.cost - a.cost) ?? [];
const entriesDisp = [];