mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 06:00:21 +08:00
dev: ll_readdir -> provider.readdir
This commit is contained in:
parent
0ef1849013
commit
29471a752f
@ -1,14 +1,22 @@
|
||||
const capabilityNames = [
|
||||
// PuterFS Capabilities
|
||||
'thumbnail',
|
||||
'uuid',
|
||||
'operation-trace',
|
||||
'readdir-uuid-mode',
|
||||
|
||||
// Standard Capabilities
|
||||
'read',
|
||||
'write',
|
||||
'case-sensitive',
|
||||
'symlink',
|
||||
'unix-perms',
|
||||
'trash',
|
||||
|
||||
// Behavior Capabilities
|
||||
'case-sensitive',
|
||||
|
||||
// POSIX Capabilities
|
||||
'readdir-inode-numbers',
|
||||
'unix-perms',
|
||||
];
|
||||
|
||||
const fsCapabilities = {};
|
||||
|
@ -17,6 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const APIError = require("../../api/APIError");
|
||||
const fsCapabilities = require("../definitions/capabilities");
|
||||
const { TYPE_SYMLINK } = require("../FSNodeContext");
|
||||
const { RootNodeSelector } = require("../node/selectors");
|
||||
const { NodeUIDSelector, NodeChildSelector } = require("../node/selectors");
|
||||
@ -51,10 +52,7 @@ class LLReadDir extends LLFilesystemOperation {
|
||||
subject = target;
|
||||
}
|
||||
|
||||
const subject_uuid = await subject.get('uid');
|
||||
|
||||
const svc = context.get('services');
|
||||
const svc_fsentry = svc.get('fsEntryService');
|
||||
const svc_fs = svc.get('filesystem');
|
||||
|
||||
if ( subject.isRoot ) {
|
||||
@ -67,16 +65,32 @@ class LLReadDir extends LLFilesystemOperation {
|
||||
];
|
||||
}
|
||||
|
||||
this.checkpoint('before get direct descendants')
|
||||
const child_uuids = await svc_fsentry
|
||||
.fast_get_direct_descendants(subject_uuid);
|
||||
this.checkpoint('after get direct descendants')
|
||||
const children = await Promise.all(child_uuids.map(async uuid => {
|
||||
return await svc_fs.node(new NodeUIDSelector(uuid));
|
||||
}));
|
||||
this.checkpoint('after get children');
|
||||
const capabilities = subject.provider.get_capabilities();
|
||||
|
||||
return children;
|
||||
// UUID Mode
|
||||
if ( capabilities.has(fsCapabilities.READDIR_UUID_MODE) ) {
|
||||
this.checkpoint('readdir uuid mode')
|
||||
const child_uuids = await subject.provider.readdir({
|
||||
context,
|
||||
node: subject,
|
||||
});
|
||||
this.checkpoint('after get direct descendants')
|
||||
const children = await Promise.all(child_uuids.map(async uuid => {
|
||||
return await svc_fs.node(new NodeUIDSelector(uuid));
|
||||
}));
|
||||
this.checkpoint('after get children');
|
||||
return children;
|
||||
}
|
||||
|
||||
// Conventional Mode
|
||||
const child_entries = subject.provider.readdir({
|
||||
context,
|
||||
node: subject,
|
||||
});
|
||||
|
||||
return await Promise.all(child_entries.map(async entry => {
|
||||
return await svc_fs.node(new NodeChildSelector(subject, entry.name));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ class PuterFSProvider {
|
||||
fsCapabilities.THUMBNAIL,
|
||||
fsCapabilities.UUID,
|
||||
fsCapabilities.OPERATION_TRACE,
|
||||
fsCapabilities.READDIR_UUID_MODE,
|
||||
|
||||
fsCapabilities.READ,
|
||||
fsCapabilities.WRITE,
|
||||
@ -110,6 +111,15 @@ class PuterFSProvider {
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
async readdir ({ context, node }) {
|
||||
const uuid = await node.get('uid');
|
||||
const services = context.get('services');
|
||||
const svc_fsentry = services.get('fsEntryService');
|
||||
const child_uuids = await svc_fsentry
|
||||
.fast_get_direct_descendants(uuid);
|
||||
return child_uuids;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
Reference in New Issue
Block a user