mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-12 20:40:52 +00:00
add safety checks for worker updates
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
This commit is contained in:
committed by
Neal Shah
parent
e9631b5a04
commit
2a8ec97c09
@@ -93,6 +93,8 @@ class WorkerService extends BaseService {
|
||||
svc_event.on('fs.write.file', async (_key, data, meta) => {
|
||||
// Code should only run on the same server as the write
|
||||
if ( meta.from_outside ) return;
|
||||
// There seems to be some bug in file writes where uid is null. We will check for this
|
||||
if ( !data.node.uid || data.node.uid === '' ) return;
|
||||
|
||||
// Check if the file that was written correlates to a worker
|
||||
const results = await svc_su.sudo(async () => {
|
||||
@@ -107,9 +109,14 @@ class WorkerService extends BaseService {
|
||||
// Person who just wrote file (not necessarily file owner)
|
||||
const actor = Context.get('actor');
|
||||
|
||||
const /** @type {string} */ workerFullName = (await result.get('subdomain'));
|
||||
if ( ! workerFullName.startsWith('workers.puter.') ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Worker data
|
||||
const fileData = (await readPuterFile(Context.get('actor'), data.node.path)).toString();
|
||||
const workerName = (await result.get('subdomain')).split('.').pop();
|
||||
const workerName = workerFullName.split('.').pop();
|
||||
|
||||
// Get appropriate deploy time auth token to give to the worker
|
||||
let authToken;
|
||||
|
||||
Reference in New Issue
Block a user