17
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
18
*/
19
19
const APIError = require ( "../../api/APIError" ) ;
20
+ const fsCapabilities = require ( "../definitions/capabilities" ) ;
20
21
const { TYPE_SYMLINK } = require ( "../FSNodeContext" ) ;
21
22
const { RootNodeSelector } = require ( "../node/selectors" ) ;
22
23
const { NodeUIDSelector, NodeChildSelector } = require ( "../node/selectors" ) ;
@@ -51,10 +52,7 @@ class LLReadDir extends LLFilesystemOperation {
51
52
subject = target ;
52
53
}
53
54
54
- const subject_uuid = await subject . get ( 'uid' ) ;
55
-
56
55
const svc = context . get ( 'services' ) ;
57
- const svc_fsentry = svc . get ( 'fsEntryService' ) ;
58
56
const svc_fs = svc . get ( 'filesystem' ) ;
59
57
60
58
if ( subject . isRoot ) {
@@ -67,16 +65,32 @@ class LLReadDir extends LLFilesystemOperation {
67
65
] ;
68
66
}
69
67
70
- this . checkpoint ( 'before get direct descendants' )
71
- const child_uuids = await svc_fsentry
72
- . fast_get_direct_descendants ( subject_uuid ) ;
73
- this . checkpoint ( 'after get direct descendants' )
74
- const children = await Promise . all ( child_uuids . map ( async uuid => {
75
- return await svc_fs . node ( new NodeUIDSelector ( uuid ) ) ;
76
- } ) ) ;
77
- this . checkpoint ( 'after get children' ) ;
68
+ const capabilities = subject . provider . get_capabilities ( ) ;
69
+
70
+ // UUID Mode
71
+ if ( capabilities . has ( fsCapabilities . READDIR_UUID_MODE ) ) {
72
+ this . checkpoint ( 'readdir uuid mode' )
73
+ const child_uuids = await subject . provider . readdir ( {
74
+ context,
75
+ node : subject ,
76
+ } ) ;
77
+ this . checkpoint ( 'after get direct descendants' )
78
+ const children = await Promise . all ( child_uuids . map ( async uuid => {
79
+ return await svc_fs . node ( new NodeUIDSelector ( uuid ) ) ;
80
+ } ) ) ;
81
+ this . checkpoint ( 'after get children' ) ;
82
+ return children ;
83
+ }
84
+
85
+ // Conventional Mode
86
+ const child_entries = subject . provider . readdir ( {
87
+ context,
88
+ node : subject ,
89
+ } ) ;
78
90
79
- return children ;
91
+ return await Promise . all ( child_entries . map ( async entry => {
92
+ return await svc_fs . node ( new NodeChildSelector ( subject , entry . name ) ) ;
93
+ } ) ) ;
80
94
}
81
95
}
82
96
0 commit comments