* Delete file or directory
()
| 341 | * Delete file or directory |
| 342 | */ |
| 343 | delete() { |
| 344 | const filename = this.#path; |
| 345 | const fullFilename = Url.join(this.#base, filename); |
| 346 | return new Promise((resolve, reject) => { |
| 347 | sftp.isConnected((connectionID) => { |
| 348 | (async () => { |
| 349 | if (this.#notConnected(connectionID)) { |
| 350 | try { |
| 351 | await this.connect(); |
| 352 | } catch (error) { |
| 353 | reject(error); |
| 354 | return; |
| 355 | } |
| 356 | } |
| 357 | await this.#setStat(); |
| 358 | sftp.rm( |
| 359 | this.#safeName(filename), |
| 360 | this.#stat.isDirectory ? true : false, |
| 361 | this.#stat.isDirectory ? true : false, |
| 362 | (_res) => { |
| 363 | resolve(fullFilename); |
| 364 | }, |
| 365 | (err) => { |
| 366 | reject(err); |
| 367 | }, |
| 368 | ); |
| 369 | })(); |
| 370 | }, reject); |
| 371 | }); |
| 372 | } |
| 373 | |
| 374 | pwd() { |
| 375 | return new Promise((resolve, reject) => { |
nothing calls this directly
no test coverage detected