-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from LarsinYousif/master
Added the ability to download a single file using the context menu
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* global STATUS_TIMEOUT */ | ||
var vscode = require("vscode"); | ||
var ftpconfig = require("./ftp-config"); | ||
var path = require("path"); | ||
var isIgnored = require("./is-ignored"); | ||
|
||
module.exports = function(fileUrl, getFtpSync) { | ||
if(!vscode.workspace.rootPath) { | ||
vscode.window.showErrorMessage("Ftp-sync: Cannot init ftp-sync without opened folder"); | ||
return; | ||
} | ||
|
||
if(fileUrl.fsPath.indexOf(vscode.workspace.rootPath) < 0) { | ||
vscode.window.showErrorMessage("Ftp-sync: Selected file is not a part of the workspace."); | ||
return; | ||
} | ||
|
||
var config = ftpconfig.getConfig(); | ||
if(isIgnored(config.ignore, fileUrl.fsPath)) { | ||
vscode.window.showErrorMessage("Ftp-sync: Selected file is ignored."); | ||
return; | ||
} | ||
|
||
var fileName = path.basename(fileUrl.fsPath); | ||
var downloadStatus = vscode.window.setStatusBarMessage("Ftp-sync: Downloading " + fileName + " from FTP server...", STATUS_TIMEOUT); | ||
getFtpSync().downloadFile(fileUrl.fsPath, vscode.workspace.rootPath, function(err) { | ||
downloadStatus.dispose(); | ||
if(err) | ||
vscode.window.showErrorMessage("Ftp-sync: Downloading " + fileName + " failed: " + err); | ||
else | ||
vscode.window.setStatusBarMessage("Ftp-sync: " + fileName + " downloaded successfully!", STATUS_TIMEOUT); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters