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

Method copyTo

src/fileSystem/sftp.js:229–255  ·  view source on GitHub ↗
(dest)

Source from the content-addressed store, hash-verified

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

Callers 1

copyToFunction · 0.45

Calls 8

#notConnectedMethod · 0.95
connectMethod · 0.95
statMethod · 0.95
#copyDirectoryMethod · 0.95
#copyFileMethod · 0.95
resolveFunction · 0.85
basenameMethod · 0.80
isConnectedMethod · 0.65

Tested by

no test coverage detected