MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / stat

Method stat

src/fileSystem/sftp.js:443–487  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

441 }
442
443 async stat() {
444 if (this.#stat) return this.#stat;
445
446 return new Promise((resolve, reject) => {
447 sftp.isConnected(async (connectionID) => {
448 (async () => {
449 if (this.#notConnected(connectionID)) {
450 try {
451 await this.connect();
452 } catch (error) {
453 reject(error);
454 return;
455 }
456 }
457
458 const path = this.#safeName(this.#path);
459
460 sftp.stat(
461 path,
462 (res) => {
463 res.url = Url.join(this.#base, res.url);
464 res.type = mimeType.lookup(path);
465 if (res.isLink) {
466 res.linkTarget = Url.join(this.#base, res.linkTarget);
467 }
468 helpers.defineDeprecatedProperty(
469 res,
470 "uri",
471 function () {
472 return this.url;
473 },
474 function (val) {
475 this.url = val;
476 },
477 );
478 resolve(res);
479 },
480 (err) => {
481 reject(err);
482 },
483 );
484 })();
485 }, reject);
486 });
487 }
488
489 get localName() {
490 return this.#getLocalname(this.#path);

Callers 4

copyToMethod · 0.95
existsMethod · 0.95
#setStatMethod · 0.95
statFunction · 0.45

Calls 5

#notConnectedMethod · 0.95
connectMethod · 0.95
#safeNameMethod · 0.95
resolveFunction · 0.85
isConnectedMethod · 0.65

Tested by

no test coverage detected