mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-08 14:10:41 -06:00
perf: make stat really fast
This commit is contained in:
@@ -81,6 +81,10 @@ class ECMAP {
|
||||
}
|
||||
}
|
||||
|
||||
store_fsNodeContext (node) {
|
||||
this.store_fsNodeContext_to_selector(node.selector, node);
|
||||
}
|
||||
|
||||
static async arun (cb) {
|
||||
let context = Context.get();
|
||||
if ( ! context.get(this.SYMBOL) ) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
const { Context } = require("../../util/context");
|
||||
const { HLFilesystemOperation } = require("./definitions");
|
||||
const APIError = require('../../api/APIError');
|
||||
const { ECMAP } = require("../ECMAP");
|
||||
|
||||
class HLStat extends HLFilesystemOperation {
|
||||
static MODULES = {
|
||||
@@ -26,6 +27,16 @@ class HLStat extends HLFilesystemOperation {
|
||||
}
|
||||
|
||||
async _run () {
|
||||
return await ECMAP.arun(async () => {
|
||||
const ecmap = Context.get(ECMAP.SYMBOL);
|
||||
ecmap.store_fsNodeContext(this.values.subject);
|
||||
return await this.__run();
|
||||
});
|
||||
}
|
||||
// async _run () {
|
||||
// return await this.__run();
|
||||
// }
|
||||
async __run () {
|
||||
const {
|
||||
subject, user,
|
||||
return_subdomains,
|
||||
@@ -35,7 +46,10 @@ class HLStat extends HLFilesystemOperation {
|
||||
return_size,
|
||||
} = this.values;
|
||||
|
||||
await subject.fetchEntry();
|
||||
await Promise.all([
|
||||
subject.fetchEntry(),
|
||||
subject.fetchIsEmpty(),
|
||||
]);
|
||||
|
||||
// file not found
|
||||
if( ! subject.found ) throw APIError.create('subject_does_not_exist');
|
||||
@@ -61,8 +75,6 @@ class HLStat extends HLFilesystemOperation {
|
||||
}
|
||||
if (return_versions) await subject.fetchVersions();
|
||||
|
||||
await subject.fetchIsEmpty();
|
||||
|
||||
return await subject.getSafeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user