mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-03 21:51:01 -05:00
fix: incorrect implementation of ll_mkdir
When ll_mkdir functionality was moved to PuterFSProvider, ACL and FSLock concerns were erroneously moved into PuterFSProvider. The intended design has ll_mkdir responsible for ACL and FSLock, and providers should never be responsible for ACL.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
const APIError = require('../../api/APIError');
|
||||
const { MODE_WRITE } = require('../../services/fs/FSLockService');
|
||||
const { Context } = require('../../util/context');
|
||||
const { NodeUIDSelector, NodeChildSelector } = require('../node/selectors');
|
||||
const { RESOURCE_STATUS_PENDING_CREATE } = require('../../modules/puterfs/ResourceService');
|
||||
const { LLFilesystemOperation } = require('./definitions');
|
||||
@@ -32,12 +31,36 @@ class LLMkdir extends LLFilesystemOperation {
|
||||
|
||||
async _run () {
|
||||
const { parent, name, immutable } = this.values;
|
||||
return await parent.provider.mkdir({
|
||||
context: this.context,
|
||||
parent,
|
||||
|
||||
const actor = this.values.actor ?? this.context.get('actor');
|
||||
|
||||
const services = this.context.get('services');
|
||||
|
||||
const svc_fsLock = services.get('fslock');
|
||||
const svc_acl = services.get('acl');
|
||||
|
||||
/* eslint-disable */ // -- Please fix this linter rule
|
||||
const lock_handle = await svc_fsLock.lock_child(
|
||||
await parent.get('path'),
|
||||
name,
|
||||
immutable,
|
||||
});
|
||||
MODE_WRITE,
|
||||
);
|
||||
/* eslint-enable */
|
||||
|
||||
try {
|
||||
if ( ! await svc_acl.check(actor, parent, 'write') ) {
|
||||
throw await svc_acl.get_safe_acl_error(actor, parent, 'write');
|
||||
}
|
||||
|
||||
return await parent.provider.mkdir({
|
||||
context: this.context,
|
||||
parent,
|
||||
name,
|
||||
immutable,
|
||||
});
|
||||
} finally {
|
||||
lock_handle.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user