mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-03 04:53:51 +01:00
BUGFIX: Infinite loop when migrating player's scripts from pre-v1.0.0 (#1798)
This commit is contained in:
parent
55627d7212
commit
3846c69204
@ -3,7 +3,7 @@ import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation
|
||||
import { Player } from "@player";
|
||||
import { GetAllServers } from "../Server/AllServers";
|
||||
import { resolveTextFilePath } from "../Paths/TextFilePath";
|
||||
import { resolveScriptFilePath } from "../Paths/ScriptFilePath";
|
||||
import { resolveScriptFilePath, type ScriptFilePath } from "../Paths/ScriptFilePath";
|
||||
|
||||
const detect: [string, string][] = [
|
||||
["getHackTime", "returns milliseconds"],
|
||||
@ -126,18 +126,29 @@ export function v1APIBreak(): void {
|
||||
home.writeToTextFile(textPath, txt);
|
||||
}
|
||||
|
||||
const backupFiles = new Map<ScriptFilePath, string>();
|
||||
for (const server of GetAllServers()) {
|
||||
backupFiles.clear();
|
||||
for (const script of server.scripts.values()) {
|
||||
if (!hasChanges(script.code)) continue;
|
||||
// Sanitize first before combining
|
||||
const oldFilename = resolveScriptFilePath(script.filename);
|
||||
const filename = resolveScriptFilePath("BACKUP_" + oldFilename);
|
||||
if (!filename) {
|
||||
console.error(`Unexpected error resolving backup path for ${script.filename}`);
|
||||
if (!hasChanges(script.code)) {
|
||||
continue;
|
||||
}
|
||||
server.writeToScriptFile(filename, script.code);
|
||||
// Sanitize first before combining
|
||||
const oldFilename = resolveScriptFilePath(script.filename);
|
||||
if (!oldFilename) {
|
||||
console.error(`Cannot resolve path for ${script.filename}`);
|
||||
continue;
|
||||
}
|
||||
const filename = resolveScriptFilePath("BACKUP_" + oldFilename);
|
||||
if (!filename) {
|
||||
console.error(`Cannot resolve backup path for ${script.filename}`);
|
||||
continue;
|
||||
}
|
||||
backupFiles.set(filename, script.code);
|
||||
script.code = convert(script.code);
|
||||
}
|
||||
for (const [filename, code] of backupFiles.entries()) {
|
||||
server.writeToScriptFile(filename, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user