()
| 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); |
no test coverage detected