(dest)
| 227 | } |
| 228 | |
| 229 | async copyTo(dest) { |
| 230 | const src = this.#path; |
| 231 | return new Promise((resolve, reject) => { |
| 232 | sftp.isConnected((connectionID) => { |
| 233 | (async () => { |
| 234 | try { |
| 235 | if (this.#notConnected(connectionID)) { |
| 236 | await this.connect(); |
| 237 | } |
| 238 | |
| 239 | const srcStat = await this.stat(); |
| 240 | |
| 241 | if (srcStat.isDirectory) { |
| 242 | await this.#copyDirectory(src, dest); |
| 243 | } else { |
| 244 | await this.#copyFile(src, dest); |
| 245 | } |
| 246 | |
| 247 | const finalPath = Path.join(dest, Path.basename(src)); |
| 248 | resolve(Url.join(this.#base, finalPath)); |
| 249 | } catch (error) { |
| 250 | reject(error); |
| 251 | } |
| 252 | })(); |
| 253 | }, reject); |
| 254 | }); |
| 255 | } |
| 256 | |
| 257 | async #copyFile(src, dest) { |
| 258 | const destPath = Path.join(dest, Path.basename(src)); |
no test coverage detected