diff --git a/src/backend/src/filesystem/definitions/capabilities.js b/src/backend/src/filesystem/definitions/capabilities.js index 84e99fd0..1eb13c42 100644 --- a/src/backend/src/filesystem/definitions/capabilities.js +++ b/src/backend/src/filesystem/definitions/capabilities.js @@ -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 = {}; diff --git a/src/backend/src/filesystem/ll_operations/ll_readdir.js b/src/backend/src/filesystem/ll_operations/ll_readdir.js index 83defc48..940bccf6 100644 --- a/src/backend/src/filesystem/ll_operations/ll_readdir.js +++ b/src/backend/src/filesystem/ll_operations/ll_readdir.js @@ -17,6 +17,7 @@ * along with this program. If not, see . */ 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)); + })); } } diff --git a/src/backend/src/modules/puterfs/lib/PuterFSProvider.js b/src/backend/src/modules/puterfs/lib/PuterFSProvider.js index b40657f7..55267a88 100644 --- a/src/backend/src/modules/puterfs/lib/PuterFSProvider.js +++ b/src/backend/src/modules/puterfs/lib/PuterFSProvider.js @@ -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 = {