| 277 | } |
| 278 | |
| 279 | async #copyDirectory(src, dest) { |
| 280 | // Create destination directory |
| 281 | const destDir = Path.join(dest, Path.basename(src)); |
| 282 | await new Promise((resolve, reject) => { |
| 283 | sftp.mkdir(this.#safeName(destDir), resolve, reject); |
| 284 | }); |
| 285 | |
| 286 | // Get contents of source directory |
| 287 | const contents = await this.lsDir(src); |
| 288 | |
| 289 | // Copy all items |
| 290 | for (const item of contents) { |
| 291 | const itemSrc = Path.join(src, item.name); |
| 292 | if (item.isDirectory) { |
| 293 | await this.#copyDirectory(itemSrc, destDir); |
| 294 | } else { |
| 295 | await this.#copyFile(itemSrc, destDir); |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | moveTo(dest) { |
| 301 | return this.rename(dest, true); |