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

Method #copyDirectory

src/fileSystem/sftp.js:279–298  ·  view source on GitHub ↗
(src, dest)

Source from the content-addressed store, hash-verified

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);

Callers 1

copyToMethod · 0.95

Calls 5

#safeNameMethod · 0.95
lsDirMethod · 0.95
#copyFileMethod · 0.95
basenameMethod · 0.80
mkdirMethod · 0.80

Tested by

no test coverage detected