spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

upload muiti files to same server directory sometimes missing files #98

Open misshy opened 6 years ago

misshy commented 6 years ago

i found that publish muti files to remote same folder that only send one file , so i try send twice (here is the code),but sometimes it will miss some files but not always. i donnot know why .please give some solution.

fileAndPublishPath.forEach(e => {            
    promises.push(this.publishFileToRemote(e['filePath'], e['publishPath'], address.sshPort, address.ip));
});
publishFileToRemote(filePath, publishPath, port, ip) {
        return new Promise((resolve, reject) => {
            client.scp(filePath, {
                host: `${ip}`,
                username: `${publishJson.USER}`,
                password: `${publishJson.PASSWORD}`,
                port: port,
                path: publishPath
            }, (err) => {
                if (err) {
                    client.scp(filePath, {
                        host: `${ip}`,
                        username: `${publishJson.USER}`,
                        password: `${publishJson.PASSWORD}`,
                        port: port,
                        path: publishPath
                    }, (err) => {
                        if (err){
                            reject(err);
                        }
                        else{
                            resolve("successful");
                        }
                    })
                } else {
                    resolve("successful");
                }
            })
        })
    }
jonataswalker commented 6 years ago

@misshy Maybe this library (https://github.com/steelbrain/node-ssh) is better for you.