This commit is contained in:
@@ -84,6 +84,7 @@ namespace PluginManager.Loaders
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PluginManager.Online.Helpers
|
||||
/// <param name="cancellation">The cancellation token</param>
|
||||
/// <returns></returns>
|
||||
internal static async Task DownloadFileAsync(this HttpClient client, string url, Stream destination,
|
||||
IProgress<float> progress = null, IProgress<long> downloadedBytes = null, CancellationToken cancellation = default)
|
||||
IProgress<float>? progress = null, IProgress<long>? downloadedBytes = null, CancellationToken cancellation = default)
|
||||
{
|
||||
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead))
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace PluginManager.Online.Helpers
|
||||
var relativeProgress = new Progress<long>(totalBytes =>
|
||||
{
|
||||
progress.Report((float)totalBytes / contentLength.Value * 100);
|
||||
downloadedBytes.Report(totalBytes);
|
||||
downloadedBytes?.Report(totalBytes);
|
||||
});
|
||||
// Use extension method to report progress while downloading
|
||||
await download.CopyToOtherStreamAsync(destination, 81920, relativeProgress, cancellation);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace PluginManager.Online
|
||||
//m_dwBytes = downloadedBytes;
|
||||
});
|
||||
|
||||
Task updateProgressBarTask = new Task(async () =>
|
||||
Task updateProgressBarTask = new Task(() =>
|
||||
{
|
||||
while (isDownloading)
|
||||
{
|
||||
|
||||
@@ -129,7 +129,8 @@ namespace PluginManager.Others
|
||||
foreach (var line in lines)
|
||||
if (line.StartsWith(Code))
|
||||
{
|
||||
File.AppendAllText(file, Code + separator + newValue + "\n"); ok = true;
|
||||
File.AppendAllText(file, Code + separator + newValue + "\n");
|
||||
ok = true;
|
||||
}
|
||||
else File.AppendAllText(file, line + "\n");
|
||||
|
||||
@@ -212,7 +213,7 @@ namespace PluginManager.Others
|
||||
/// <exception cref="ArgumentOutOfRangeException">Triggered if <paramref name="bufferSize"/> is less then or equal to 0</exception>
|
||||
/// <exception cref="InvalidOperationException">Triggered if <paramref name="stream"/> is not readable</exception>
|
||||
/// <exception cref="ArgumentException">Triggered in <paramref name="destination"/> is not writable</exception>
|
||||
public static async Task CopyToOtherStreamAsync(this Stream stream, Stream destination, int bufferSize, IProgress<long> progress = null, CancellationToken cancellationToken = default)
|
||||
public static async Task CopyToOtherStreamAsync(this Stream stream, Stream destination, int bufferSize, IProgress<long>? progress = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
|
||||
Reference in New Issue
Block a user