mirror of https://github.com/winsw/winsw
Fix download exceptions when ignoring errors
parent
b774ee1ca5
commit
03d0ccc4d7
|
@ -193,10 +193,14 @@ namespace WinSW
|
||||||
if (supportsIfModifiedSince && ((HttpWebResponse?)e.Response)?.StatusCode == HttpStatusCode.NotModified)
|
if (supportsIfModifiedSince && ((HttpWebResponse?)e.Response)?.StatusCode == HttpStatusCode.NotModified)
|
||||||
{
|
{
|
||||||
Logger.Info($"Skipped downloading unmodified resource '{this.From}'");
|
Logger.Info($"Skipped downloading unmodified resource '{this.From}'");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
string errorMessage = $"Failed to download {this.From} to {this.To}";
|
||||||
|
Logger.Error(errorMessage, e);
|
||||||
|
if (this.FailOnError)
|
||||||
{
|
{
|
||||||
throw;
|
throw new IOException(errorMessage, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,32 +272,7 @@ namespace WinSW
|
||||||
tasks[i] = download.PerformAsync();
|
tasks[i] = download.PerformAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
}
|
|
||||||
catch (AggregateException e)
|
|
||||||
{
|
|
||||||
var exceptions = new List<Exception>(e.InnerExceptions.Count);
|
|
||||||
for (int i = 0; i < tasks.Length; i++)
|
|
||||||
{
|
|
||||||
if (tasks[i].IsFaulted)
|
|
||||||
{
|
|
||||||
var download = downloads[i];
|
|
||||||
string errorMessage = $"Failed to download {download.From} to {download.To}";
|
|
||||||
var exception = tasks[i].Exception!;
|
|
||||||
Log.Error(errorMessage, exception);
|
|
||||||
|
|
||||||
// TODO: move this code into the download logic
|
|
||||||
if (download.FailOnError)
|
|
||||||
{
|
|
||||||
exceptions.Add(new IOException(errorMessage, exception));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AggregateException(exceptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
var sharedDirectories = this.config.SharedDirectories;
|
var sharedDirectories = this.config.SharedDirectories;
|
||||||
if (sharedDirectories.Count > 0)
|
if (sharedDirectories.Count > 0)
|
||||||
|
|
Loading…
Reference in New Issue