You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have multiple task to download file and use Task.WaitAll to wait them to finished. All the download task share the same cancellation token source. The issue appear when I cancel the token and all files are deleted even though some of the task is finished already. Something must be wrong in the flush method. Below is the test case code:
using Microsoft.Extensions.Logging;
using OctaneEngine;
using OctaneEngineCore;
using Serilog;
using ILogger = Serilog.ILogger;
namespace TestOctaneEngineMain;
public static class Program
{
private static readonly CancellationTokenSource Cts = new();
public static void Main(string[] args)
{
Console.CancelKeyPress += delegate
{
Cts.Cancel();
Console.WriteLine("Cancelling task");
};
Console.WriteLine("Hello, World!");
ILogger log = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Verbose()
.WriteTo.Console()
.CreateLogger();
var loggerFactory = LoggerFactory.Create(logging =>
{
logging.AddSerilog(log);
});
var config = new OctaneConfiguration
{
Parts = 8,
LowMemoryMode = false,
BufferSize = 8196,
ShowProgress = false,
NumRetries = 3,
BytesPerSecond = 1,
UseProxy = false
};
var localFile = "/local/path/bigfilename.txt";
var bigFileUrl = "http://url/bigfilename.txt";
var smallLocalFile = "/local/path/smallfilename.txt";
var smallFileUrl = "http://url/smallfilename.txt";
IEngine? bigFileDownloader = EngineBuilder.Build(loggerFactory, config);
bigFileDownloader.SetDoneCallback( status => Console.WriteLine(status ? "Done callback big file called" : "Error Done callback big file called"));
IEngine? smallFileDownloader = EngineBuilder.Build(loggerFactory, config);
smallFileDownloader.SetDoneCallback(status => Console.WriteLine(status ? "Done callback small file called" : "Error Done callback small file called"));
var pt = new PauseTokenSource();
var tasks = new List<Task>();
tasks.Add(
bigFileDownloader.DownloadFile(bigFileUrl, localFile, pt, Cts)
.ContinueWith(_ => Console.WriteLine("Done download big file continuation")));
tasks.Add(
smallFileDownloader.DownloadFile(smallFileUrl, smallLocalFile, pt, Cts)
.ContinueWith(_ => Console.WriteLine("Done download small file continuation")));
Task.WaitAll(tasks.ToArray());
Console.WriteLine("Download all files finished!");
}
}
To Reproduce
Just run the code above, change the URL to some big and small file. Wait for the small file to finish and press ctrl+c. Both file will be deleted in local folder.
Expected behavior
Finished file should be there and not deleted.
Additional context
This bug is tested in version 8.0.3 and 8.0.4.
The text was updated successfully, but these errors were encountered:
Describe the bug
I have multiple task to download file and use Task.WaitAll to wait them to finished. All the download task share the same cancellation token source. The issue appear when I cancel the token and all files are deleted even though some of the task is finished already. Something must be wrong in the flush method. Below is the test case code:
To Reproduce
Just run the code above, change the URL to some big and small file. Wait for the small file to finish and press ctrl+c. Both file will be deleted in local folder.
Expected behavior
Finished file should be there and not deleted.
Additional context
This bug is tested in version 8.0.3 and 8.0.4.
The text was updated successfully, but these errors were encountered: