Skip to content

Commit

Permalink
Notify browser of upload error on agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Aug 8, 2020
1 parent 15ef6d4 commit 1eae0ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Agent.Installer.Win/Services/InstallerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ private async Task DownloadRemotelyAgent(string serverUrl)
{
var targetFile = Path.Combine(Path.GetTempPath(), $"Remotely-Agent.zip");

if (CommandLineParser.CommandLineArgs.TryGetValue("path", out var result))
if (CommandLineParser.CommandLineArgs.TryGetValue("path", out var result) &&
FileIO.Exists(result))
{
FileIO.Copy(result, targetFile, true);
targetFile = result;
}
else
{
Expand Down
15 changes: 12 additions & 3 deletions Agent/Services/AgentSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,18 @@ private void RegisterMessageHandlers()
await HubConnection.SendAsync("DownloadFileProgress", lastProgressPercent, senderConnectionID);
}
};
var response = await wc.UploadFileTaskAsync($"{ConnectionInfo.Host}/API/FileSharing/", filePath);
var fileIDs = JsonSerializer.Deserialize<string[]>(Encoding.UTF8.GetString(response));
await HubConnection.SendAsync("DownloadFile", fileIDs[0], senderConnectionID);
try
{
var response = await wc.UploadFileTaskAsync($"{ConnectionInfo.Host}/API/FileSharing/", filePath);
var fileIDs = JsonSerializer.Deserialize<string[]>(Encoding.UTF8.GetString(response));
await HubConnection.SendAsync("DownloadFile", fileIDs[0], senderConnectionID);
}
catch (Exception ex)
{
Logger.Write(ex);
await HubConnection.SendAsync("DisplayMessage", "Error occurred while uploading file from remote computer.", "Upload error.", senderConnectionID);
}
});
HubConnection.On("ChangeWindowsSession", async (string serviceID, string viewerID, int targetSessionID) =>
{
Expand Down

0 comments on commit 1eae0ba

Please sign in to comment.