diff --git a/CompatBot/Commands/Bot.cs b/CompatBot/Commands/Bot.cs index e1344808..1ac95a2b 100644 --- a/CompatBot/Commands/Bot.cs +++ b/CompatBot/Commands/Bot.cs @@ -47,10 +47,7 @@ internal static partial class Bot } await using var result = Config.MemoryStreamManager.GetStream(); - using var zip = new ZipWriter( - result, - new(CompressionType.LZMA) { DeflateCompressionLevel = CompressionLevel.Default } - ); + using var zip = new ZipWriter(result, new(CompressionType.LZMA)); foreach (var fname in logPaths) { await using var log = File.Open(fname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); @@ -213,7 +210,7 @@ internal static partial class Bot await wdb.SaveChangesAsync().ConfigureAwait(false); } } - using (var zip = new ZipWriter(result, new(CompressionType.LZMA){DeflateCompressionLevel = CompressionLevel.Default})) + using (var zip = new ZipWriter(result, new(CompressionType.LZMA))) foreach (var fname in Directory.EnumerateFiles(dbDir, $"{dbName}.*", new EnumerationOptions { IgnoreInaccessible = true, RecurseSubdirectories = false, })) { await using var dbData = File.Open(fname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); @@ -243,9 +240,9 @@ internal static partial class Bot private static async ValueTask UpdateCheckAsync(SlashCommandContext? ctx, CancellationToken cancellationToken) { // ReSharper disable once MethodHasAsyncOverloadWithCancellation -#pragma warning disable VSTHRD103 +#pragma warning disable VSTHRD103, CA2016 if (!LockObj.Wait(0)) -#pragma warning restore VSTHRD103 +#pragma warning restore VSTHRD103, CA2016 { Config.Log.Info("Update check is already in progress"); if (ctx is not null) diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs index c53468a5..38cd9bca 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs @@ -76,7 +76,8 @@ internal sealed partial class GoogleDriveHandler: BaseSourceHandler private static DriveService GetClient(string? json = null) { - var credential = GoogleCredential.FromJson(json ?? Config.GoogleApiCredentials).CreateScoped(Scopes); + var credFactory = CredentialFactory.FromJson(json ?? Config.GoogleApiCredentials); + var credential = credFactory.ToGoogleCredential().CreateScoped(Scopes); var service = new DriveService(new() { HttpClientInitializer = credential, @@ -99,7 +100,7 @@ internal sealed partial class GoogleDriveHandler: BaseSourceHandler } } - private sealed class GoogleDriveSource : ISource + private sealed class GoogleDriveSource(DriveService driveService, FilesResource.GetRequest fileInfoRequest, FileMeta fileMeta, IArchiveHandler handler) : ISource { public string SourceType => "Google Drive"; public string FileName => fileMeta.Name; @@ -107,19 +108,6 @@ internal sealed partial class GoogleDriveHandler: BaseSourceHandler public long SourceFilePosition => handler.SourcePosition; public long LogFileSize => handler.LogSize; - private readonly DriveService driveService; - private readonly FilesResource.GetRequest fileInfoRequest; - private readonly FileMeta fileMeta; - private readonly IArchiveHandler handler; - - public GoogleDriveSource(DriveService driveService, FilesResource.GetRequest fileInfoRequest, FileMeta fileMeta, IArchiveHandler handler) - { - this.driveService = driveService; - this.fileInfoRequest = fileInfoRequest; - this.fileMeta = fileMeta; - this.handler = handler; - } - public async Task FillPipeAsync(PipeWriter writer, CancellationToken cancellationToken) { try diff --git a/CompatBot/ThumbScrapper/GameTdbScraper.cs b/CompatBot/ThumbScrapper/GameTdbScraper.cs index df3ca4b6..b56bb3c3 100644 --- a/CompatBot/ThumbScrapper/GameTdbScraper.cs +++ b/CompatBot/ThumbScrapper/GameTdbScraper.cs @@ -81,8 +81,7 @@ internal static partial class GameTdbScraper await downloadStream.CopyToAsync(fileStream, 16384, cancellationToken).ConfigureAwait(false); fileStream.Seek(0, SeekOrigin.Begin); using var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Read); - var logEntry = zipArchive.Entries.FirstOrDefault(e => e.Name.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)); - if (logEntry == null) + if (zipArchive.Entries.FirstOrDefault(e => e.Name.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)) is not {} logEntry) throw new InvalidOperationException("No zip entries that match the .xml criteria"); await using var zipStream = logEntry.Open();