Skip to content

Commit

Permalink
fixes #22, uploadOnSave will fail for files on new created folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz.wronski committed Jan 16, 2016
1 parent df2d267 commit 6bfcdd9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -52,6 +52,9 @@ Use at your own risk - I do not guarantee that it will work correctly!

## Version history

- 0.2.9
- Fix for [uploadOnSave will fail for files on new created folders](https://github.com/lukasz-wronski/vscode-ftp-sync/issues/22)
- Added ES6 support in extension source
- 0.2.8
- Attempt to fix [uploadOnSave will fail for files on new created folders](https://github.com/lukasz-wronski/vscode-ftp-sync/issues/22)
- 0.2.7
Expand Down
2 changes: 1 addition & 1 deletion jsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"target": "ES6",
"noLib": true
},
"exclude": [
Expand Down
33 changes: 18 additions & 15 deletions modules/sync-helper.js
Expand Up @@ -291,22 +291,25 @@ var uploadFile = function(localPath, rootPath, callback) {
var remotePath = upath.toUnix(path.join(ftpConfig.remote, localPath.replace(rootPath, '')));
var remoteDir = upath.toUnix(path.dirname(remotePath));
connect(function(err) {
if(err) callback(err);
else ftp.list(remoteDir, function(err) {
if(!err) {
ftp.put(localPath, remotePath, function(err) {
callback(err);
})
} else if(err.code == 450 || err.code == 550) {
ftp.mkdir(remoteDir, true, function(err) {
if(err) callback(err)
else ftp.put(localPath, remotePath, function(err) {
if(err) callback(err);
var putFile = function() {
ftp.put(localPath, remotePath, function(err) {
callback(err);
})
})
} else
callback(err)
});
})
}
if(remoteDir != ".")
ftp.list(path.join(remoteDir, ".."), function(err, list) {
if(err) callback(err);
else if(_.any(list, f => f.name == path.basename(remoteDir)))
putFile();
else
ftp.mkdir(remoteDir, true, function(err) {
if(err) callback(err)
else putFile();
})
});
else
putFile();
})
}

Expand Down

0 comments on commit 6bfcdd9

Please sign in to comment.