Allow relative paths for creating puter s2w workers

This commit is contained in:
ProgrammerIn-wonderland
2025-07-29 13:15:59 -07:00
committed by Eric Dubé
parent 050ad0f785
commit f962a6a838
2 changed files with 9 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ const { Eq } = require("../../om/query/query");
const { get_app } = require("../../helpers");
const { UsernameNotifSelector } = require("../NotificationService");
const APIError = require("../../api/APIError");
const FSNodeParam = require("../../api/filesystem/FSNodeParam");
async function readPuterFile(actor, filePath) {
try {
@@ -189,7 +190,11 @@ class WorkerService extends BaseService {
try {
workerName = workerName.toLocaleLowerCase(); // just incase
if(!(/^[a-zA-Z0-9_]+$/.test(workerName))) return;
filePath = await (await (new FSNodeParam('path')).consolidate({
req: { user: Context.get("actor").type.user },
getParam: () => filePath,
})).get("path");
const userData = await getUserInfo(authorization, this.global_config.api_base_url);
const actor = Context.get("actor");
const es_subdomain = this.services.get('es:subdomain');

View File

@@ -1,3 +1,5 @@
import getAbsolutePathForApp from "./FileSystem/utils/getAbsolutePathForApp.js";
export class WorkersHandler {
constructor(authToken) {
@@ -10,6 +12,7 @@ export class WorkersHandler {
if (!currentWorkers) {
currentWorkers = {};
}
filePath = getAbsolutePathForApp(filePath);
const driverCall = await puter.drivers.call("workers", "worker-service", "create", { authorization: puter.authToken, filePath, workerName });
const driverResult = driverCall.result;