Skip to content

Commit

Permalink
Handle file renames or creates as well (for visual studio in particul…
Browse files Browse the repository at this point in the history
…ar).
  • Loading branch information
mitchcapper committed Dec 13, 2016
1 parent 1366422 commit e3651bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Model/SFTPFileUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ private async Task UploadFile(String filename, String remote_name) {
if (e.Message == "Channel was closed.") {
disconnect();
MainWindow.ShowMessage("Connection to server lost details: " + e.Message, "Lost Connection");
} else if (e.Message == "Failure.") {
disconnect();
MainWindow.ShowMessage("General failure from SSH Libary", "General Failure");
} else
throw e;
}
}
}
public void disconnect() {
if (client != null) {
try {
Expand Down
14 changes: 12 additions & 2 deletions ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@ public MainViewModel() {
uploader.UploadEvtProgress += UploadEvtProgress;
uploader.ConnectedChanged += ConnectedChanged;
watcher = new FileSystemWatcher();
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
watcher.Changed += FileChanged;
watcher.Renamed += FileRenamed;
watcher.Created += FileCreated;
UpdateButton();
try {
ignore_regex = settings.ignore_regex;
} catch (Exception) {}
}

private void FileCreated(object sender, FileSystemEventArgs e) {
uploader.AddFileUpload(e.FullPath);
}

private void FileRenamed(object sender, RenamedEventArgs e) {
uploader.AddFileUpload(e.FullPath);
}

public void loaded() {
var args = Environment.GetCommandLineArgs();
if (args.Length == 2) {
Expand All @@ -53,7 +64,6 @@ public string title {
private string _title;

private void ConnectedChanged(object sender, EventArgs event_args) {
Debug.WriteLine("Connection changed status is: " + connected);
UpdateButton();
if (connected)
StartWatcher();
Expand Down

0 comments on commit e3651bc

Please sign in to comment.