From 32e2b8a0c5cdd660da3c792dcfc72fa4f615d9fe Mon Sep 17 00:00:00 2001 From: 4censord Date: Sat, 28 May 2022 13:46:03 +0200 Subject: [PATCH 1/2] Ignore warning CS0618 in Library.cs In Library.cs there was this warning: OpenDirectoryDownloader/Library.cs(220,32): warning CS0618: 'FtpClient.OpenReadAsync(string, FtpDataType, long, bool, CancellationToken)' is obsolete: 'OpenReadAsync() is obsolete, please use DownloadAsync() or DownloadFileAsync() instead' This is caused by github.com/robinrodricks/FluentFTP marking the `OpenRead` and `OpenWrite` methods as deprecated This is further discussed at https://github.com/robinrodricks/FluentFTP/issues/841 TLDR: They will not be removed in the near future. This has been done because they are not part of the `public` api. If they remove them, they will provide a different streaming api. --- src/OpenDirectoryDownloader/Library.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OpenDirectoryDownloader/Library.cs b/src/OpenDirectoryDownloader/Library.cs index 549430f2..5987d618 100644 --- a/src/OpenDirectoryDownloader/Library.cs +++ b/src/OpenDirectoryDownloader/Library.cs @@ -216,12 +216,13 @@ public static async Task DoSpeedTestFtpAsync(FtpClient ftpClien Logger.Info($"Do FTP speedtest for {url}"); Uri uri = new Uri(url); - - using (Stream stream = await ftpClient.OpenReadAsync(uri.LocalPath)) + #pragma warning disable CS0618 // Discussion about `OpenRead` https://github.com/robinrodricks/FluentFTP/issues/841 + using (Stream stream = ftpClient.OpenRead(uri.LocalPath)) + #pragma warning restore CS0618 { SpeedtestResult speedtestResult = SpeedtestFromStream(stream, seconds); - return speedtestResult; + return await Task.FromResult(speedtestResult); } } From 296e6d0cc5125e45d22f506782c12a1e07d0c4e0 Mon Sep 17 00:00:00 2001 From: 4censord Date: Sat, 28 May 2022 14:06:25 +0200 Subject: [PATCH 2/2] Fix warning CS1998 in Site/Pixeldrain/PixeldrainParser.cs In PixeldrainParser.cs there was this warning OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs (45,42): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run (...)' to do CPU-bound work on a background thread. This is caused by using a synchronous operation in an asynchronous context. Specifically `return` is synchronous. This is fixed by wrapping the returned value into `Task.FromResult()` and awaiting that. --- src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs b/src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs index 3f4f27e0..30b52760 100644 --- a/src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs +++ b/src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainParser.cs @@ -117,6 +117,6 @@ private static async Task ScanAsync(HttpClient httpClient, WebDire //throw; } - return webDirectory; + return await Task.FromResult(webDirectory); } }