mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Fix empty etag issue.
This commit is contained in:
parent
4041c14cfc
commit
674036601e
@ -70,28 +70,21 @@ namespace Remotely.Agent.Services
|
||||
|
||||
var fileUrl = serverUrl + $"/Content/Remotely-Linux.zip";
|
||||
|
||||
var lastEtag = string.Empty;
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
|
||||
if (File.Exists("etag.txt"))
|
||||
{
|
||||
lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
var lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
if (!string.IsNullOrEmpty(lastEtag))
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
}
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
@ -102,6 +95,11 @@ namespace Remotely.Agent.Services
|
||||
await InstallLatestVersion();
|
||||
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
|
||||
@ -71,28 +71,21 @@ namespace Remotely.Agent.Services
|
||||
|
||||
var fileUrl = serverUrl + $"/Content/Remotely-MacOS-{_achitecture}.zip";
|
||||
|
||||
var lastEtag = string.Empty;
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
|
||||
if (File.Exists("etag.txt"))
|
||||
{
|
||||
lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
var lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
if (!string.IsNullOrEmpty(lastEtag))
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
}
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
@ -103,6 +96,11 @@ namespace Remotely.Agent.Services
|
||||
await InstallLatestVersion();
|
||||
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
|
||||
@ -66,37 +66,36 @@ namespace Remotely.Agent.Services
|
||||
var platform = Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
var fileUrl = serverUrl + $"/Content/Remotely-Win10-{platform}.zip";
|
||||
|
||||
var lastEtag = string.Empty;
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
|
||||
if (File.Exists("etag.txt"))
|
||||
{
|
||||
lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
var lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
if (!string.IsNullOrEmpty(lastEtag))
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(lastEtag));
|
||||
}
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Logger.Write("Service Updater: Update found.");
|
||||
|
||||
await InstallLatestVersion();
|
||||
|
||||
}
|
||||
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
Logger.Write("Service Updater: Version is current.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user