fileExists no longer case sensitive for programs

This commit is contained in:
omuretsu
2023-05-27 08:34:14 -04:00
parent ad3b217b8f
commit 8bf13b6fd3
3 changed files with 17 additions and 24 deletions
+13 -15
View File
@@ -1125,21 +1125,19 @@ export const ns: InternalAPI<NSFull> = {
const hostname = helpers.string(ctx, "hostname", _hostname);
return GetServer(hostname) !== null;
},
fileExists:
(ctx) =>
(_filename, _hostname = ctx.workerScript.hostname) => {
const filename = helpers.string(ctx, "filename", _filename);
const hostname = helpers.string(ctx, "hostname", _hostname);
const server = helpers.getServer(ctx, hostname);
const path = resolveFilePath(filename, ctx.workerScript.name);
if (!path) return false;
if (hasScriptExtension(path)) return server.scripts.has(path);
if (hasTextExtension(path)) return server.textFiles.has(path);
if (hasProgramExtension(path)) return server.programs.includes(path);
if (path.endsWith(".lit") || path.endsWith(".msg")) return server.messages.includes(path as any);
if (hasContractExtension(path)) return !!server.contracts.find(({ fn }) => fn === path);
return false;
},
fileExists: (ctx) => (_filename, _hostname) => {
const filename = helpers.string(ctx, "filename", _filename);
const hostname = helpers.string(ctx, "hostname", _hostname ?? ctx.workerScript.hostname);
const server = helpers.getServer(ctx, hostname);
const path = resolveFilePath(filename, ctx.workerScript.name);
if (!path) return false;
if (hasScriptExtension(path)) return server.scripts.has(path);
if (hasTextExtension(path)) return server.textFiles.has(path);
if (path.endsWith(".lit") || path.endsWith(".msg")) return server.messages.includes(path as any);
if (hasContractExtension(path)) return !!server.contracts.find(({ fn }) => fn === path);
const lowerPath = path.toLowerCase();
return server.programs.map((programName) => programName.toLowerCase()).includes(lowerPath);
},
isRunning:
(ctx) =>
(fn, hostname, ...scriptArgs) => {