mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
Program path bugfix + wget use contentFile
This commit is contained in:
parent
8fd4eee8e9
commit
350679bc83
@ -1626,7 +1626,7 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
wget: (ctx) => async (_url, _target, _hostname) => {
|
wget: (ctx) => (_url, _target, _hostname) => {
|
||||||
const url = helpers.string(ctx, "url", _url);
|
const url = helpers.string(ctx, "url", _url);
|
||||||
const target = helpers.filePath(ctx, "target", _target);
|
const target = helpers.filePath(ctx, "target", _target);
|
||||||
const hostname = _hostname ? helpers.string(ctx, "hostname", _hostname) : ctx.workerScript.hostname;
|
const hostname = _hostname ? helpers.string(ctx, "hostname", _hostname) : ctx.workerScript.hostname;
|
||||||
@ -1640,11 +1640,7 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
url,
|
url,
|
||||||
function (data) {
|
function (data) {
|
||||||
let res;
|
let res;
|
||||||
if (hasScriptExtension(target)) {
|
res = server.writeToContentFile(target, data);
|
||||||
res = server.writeToScriptFile(target, data);
|
|
||||||
} else {
|
|
||||||
res = server.writeToTextFile(target, data);
|
|
||||||
}
|
|
||||||
if (res.overwritten) {
|
if (res.overwritten) {
|
||||||
helpers.log(ctx, () => `Successfully retrieved content and overwrote '${target}' on '${hostname}'`);
|
helpers.log(ctx, () => `Successfully retrieved content and overwrote '${target}' on '${hostname}'`);
|
||||||
return resolve(true);
|
return resolve(true);
|
||||||
|
@ -9,7 +9,7 @@ export type ProgramFilePath = FilePath & WithProgramExtension;
|
|||||||
export function hasProgramExtension(path: string): path is WithProgramExtension {
|
export function hasProgramExtension(path: string): path is WithProgramExtension {
|
||||||
if (path.endsWith(".exe")) return true;
|
if (path.endsWith(".exe")) return true;
|
||||||
const extension = path.substring(path.indexOf("."));
|
const extension = path.substring(path.indexOf("."));
|
||||||
return /^\.exe-[0-9]{1-2}\.[0-9]{2}%-INC$/.test(extension);
|
return /^\.exe-[0-9]{1,2}\.[0-9]{2}%-INC$/.test(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sanitize a player input, resolve any relative paths, and for imports add the correct extension if missing */
|
/** Sanitize a player input, resolve any relative paths, and for imports add the correct extension if missing */
|
||||||
|
Loading…
Reference in New Issue
Block a user