fix some compilation warnings

This commit is contained in:
13xforever
2025-12-27 06:14:12 +05:00
parent b98bd3daee
commit 7cbaa3ff55
3 changed files with 8 additions and 24 deletions

View File

@@ -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)

View File

@@ -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<ServiceAccountCredential>(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

View File

@@ -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();