Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ jobs:
- name: Update dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
dotnet-version: 10.0.x

- name: Checkout repository
uses: actions/checkout@v4
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ jobs:
- name: update dotnet core sdk
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
dotnet-version: 10.0.x
- name: dotnet restore (first try)
run: dotnet restore --ignore-failed-sources
- name: dotnet restore (second try)
Expand All @@ -37,9 +35,7 @@ jobs:
- name: update dotnet core sdk
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
dotnet-version: 10.0.x
- name: dotnet restore (first try)
run: dotnet restore --ignore-failed-sources
- name: dotnet restore (second try)
Expand Down Expand Up @@ -74,9 +70,7 @@ jobs:
- name: update dotnet core sdk
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
dotnet-version: 10.0.x
- name: dotnet restore (first try)
run: dotnet restore --ignore-failed-sources
- name: dotnet restore (second try)
Expand Down
2 changes: 1 addition & 1 deletion Clients/CirrusCiClient/CirrusCiClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion Clients/CompatApiClient/CompatApiClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Clients/GithubClient/Client.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public async Task<PipelineStats> GetPipelineDurationAsync(CancellationToken canc
.ToList();
return await builds
.ToAsyncEnumerable()
.SelectAwait(async b => await GetArtifactsInfoAsync(b.HeadSha, b, cancellationToken).ConfigureAwait(false))
.Select((b, ct) => GetArtifactsInfoAsync(b.HeadSha, b, ct))
.ToListAsync(cancellationToken: cancellationToken)
.ConfigureAwait(false);
}
Expand Down
5 changes: 2 additions & 3 deletions Clients/GithubClient/GithubClient.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="SharpCompress" Version="0.42.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion Clients/IrdLibraryClient/IrdLibraryClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Clients/MediafireClient/MediafireClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Clients/OneDriveClient/OneDriveClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Clients/PsnClient/PsnClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Clients/YandexDiskClient/YandexDiskClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
5 changes: 3 additions & 2 deletions CompatBot/Commands/Sudo.Mod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CompatBot.Database.Providers;
using CompatBot.Database;
using CompatBot.Database.Providers;

namespace CompatBot.Commands;

Expand Down Expand Up @@ -80,7 +81,7 @@ public static async ValueTask List(SlashCommandContext ctx)
var modList = ModProvider.Mods
.Values
.ToAsyncEnumerable()
.SelectAwait(async m =>(m: m, u: await ctx.Client.GetUserAsync(m.DiscordId).ConfigureAwait(false)))
.Select(async (Moderator m, CancellationToken _) => (m: m, u: await ctx.Client.GetUserAsync(m.DiscordId).ConfigureAwait(false)))
.OrderByDescending(i => i.m.Sudoer)
.ThenBy(i => i.u.Username)
.ToList();
Expand Down
10 changes: 5 additions & 5 deletions CompatBot/CompatBot.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<TieredCompilation>true</TieredCompilation>
<RootNamespace>CompatBot</RootNamespace>
<UserSecretsId>c2e6548b-b215-4a18-a010-958ef294b310</UserSecretsId>
Expand Down Expand Up @@ -55,12 +55,12 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.23.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.23.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.1" />
Expand All @@ -72,9 +72,9 @@
<PackageReference Include="NLog" Version="6.0.7" />
<PackageReference Include="NLog.Extensions.Logging" Version="6.1.0" />
<PackageReference Include="NReco.Text.AhoCorasickDoubleArrayTrie" Version="1.1.1" />
<PackageReference Include="Result.Net" Version="1.7.0" />
<PackageReference Include="SharpCompress" Version="0.42.1" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="TesseractCSharp" Version="1.0.5" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions CompatBot/Database/Providers/DiscLanguageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private static string MapLangToFlag(char region, string lang)
["Italy"] = "🇮🇹",
["Japan"] = "🇯🇵",
["Korea"] = "🇰🇷",
["Latin America"] = "🇱🇽", // not a real code
["Mexico"] = "🇲🇽",
["New Zealand"] = "🇳🇿",
["Poland"] = "🇵🇱",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.IO.Compression;
using System.IO.Pipelines;
using ResultNet;

namespace CompatBot.EventHandlers.LogParsing.ArchiveHandlers;

Expand All @@ -11,17 +12,17 @@ internal sealed class GzipHandler: IArchiveHandler
public long LogSize { get; private set; }
public long SourcePosition { get; private set; }

public (bool result, string? reason) CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
public Result CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
{
if (header.Length >= Header.Length)
{
if (header[..Header.Length].SequenceEqual(Header))
return (true, null);
return Result.Success();
}
else if (fileName.EndsWith(".log.gz", StringComparison.InvariantCultureIgnoreCase)
&& !fileName.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
return (true, null);
return (false, null);
return Result.Success();
return Result.Failure();
}

public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.IO;
using System.IO.Pipelines;
using ResultNet;

namespace CompatBot.EventHandlers.LogParsing.ArchiveHandlers;

public interface IArchiveHandler
{
(bool result, string? reason) CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header);
Result CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header);
Task FillPipeAsync(Stream sourceStream, PipeWriter writer, CancellationToken cancellationToken);
long LogSize { get; }
long SourcePosition { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.IO.Pipelines;
using ResultNet;

namespace CompatBot.EventHandlers.LogParsing.ArchiveHandlers;

Expand All @@ -8,16 +9,16 @@ internal sealed class PlainTextHandler: IArchiveHandler
public long LogSize { get; private set; }
public long SourcePosition { get; private set; }

public (bool result, string? reason) CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
public Result CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
{
LogSize = fileSize;
if (fileName.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
return (false, null);
return Result.Failure();

if (header.Length > 10 && Encoding.UTF8.GetString(header[..30]).Contains("RPCS3 v"))
return (true, null);
return Result.Success();

return (false, null);
return Result.Failure();
}

public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, CancellationToken cancellationToken)
Expand Down
13 changes: 7 additions & 6 deletions CompatBot/EventHandlers/LogParsing/ArchiveHandlers/RarHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.IO.Pipelines;
using ResultNet;
using SharpCompress.Readers.Rar;

namespace CompatBot.EventHandlers.LogParsing.ArchiveHandlers;
Expand All @@ -11,17 +12,17 @@ internal sealed class RarHandler: IArchiveHandler
public long LogSize { get; private set; }
public long SourcePosition { get; private set; }

public (bool result, string? reason) CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
public Result CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
{
if (header.Length >= Header.Length && header[..Header.Length].SequenceEqual(Header)
|| header.Length == 0 && fileName.EndsWith(".rar", StringComparison.InvariantCultureIgnoreCase))
{
var firstEntry = Encoding.ASCII.GetString(header);
if (!firstEntry.Contains(".log", StringComparison.InvariantCultureIgnoreCase))
return (false, "Archive doesn't contain any logs.");
return (true, null);
return Result.Failure().WithMessage("Archive doesn't contain any logs.");
return Result.Success();
}
return (false, null);
return Result.Failure();
}

public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, CancellationToken cancellationToken)
Expand All @@ -30,14 +31,14 @@ public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, Cancella
{
await using var statsStream = new BufferCopyStream(sourceStream);
using var rarReader = RarReader.Open(statsStream);
while (rarReader.MoveToNextEntry())
while (await rarReader.MoveToNextEntryAsync(cancellationToken).ConfigureAwait(false))
{
if (!rarReader.Entry.IsDirectory
&& rarReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !rarReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = rarReader.Entry.Size;
await using var rarStream = rarReader.OpenEntryStream();
await using var rarStream = await rarReader.OpenEntryStreamAsync(cancellationToken).ConfigureAwait(false);
int read;
FlushResult flushed;
do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.IO.Pipelines;
using CompatApiClient.Utils;
using ResultNet;
using SharpCompress.Archives.SevenZip;

namespace CompatBot.EventHandlers.LogParsing.ArchiveHandlers;
Expand All @@ -12,16 +13,16 @@ internal sealed class SevenZipHandler: IArchiveHandler
public long LogSize { get; private set; }
public long SourcePosition { get; private set; }

public (bool result, string? reason) CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
public Result CanHandle(string fileName, int fileSize, ReadOnlySpan<byte> header)
{
if (header.Length >= Header.Length && header[..Header.Length].SequenceEqual(Header)
|| header.Length == 0 && fileName.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase))
{
if (fileSize > Config.AttachmentSizeLimit)
return (false, $"Log size is too large for 7z format: {fileSize.AsStorageUnit()} (max allowed is {Config.AttachmentSizeLimit.AsStorageUnit()})");
return (true, null);
return Result.Failure().WithMessage($"Log size is too large for 7z format: {fileSize.AsStorageUnit()} (max allowed is {Config.AttachmentSizeLimit.AsStorageUnit()})");
return Result.Success();
}
return (false, null);
return Result.Failure();
}

public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, CancellationToken cancellationToken)
Expand All @@ -33,13 +34,13 @@ public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, Cancella
fileStream.Seek(0, SeekOrigin.Begin);
using var zipArchive = SevenZipArchive.Open(fileStream);
using var zipReader = zipArchive.ExtractAllEntries();
while (zipReader.MoveToNextEntry())
while (await zipReader.MoveToNextEntryAsync(cancellationToken).ConfigureAwait(false))
if (!zipReader.Entry.IsDirectory
&& zipReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !zipReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = zipReader.Entry.Size;
await using var entryStream = zipReader.OpenEntryStream();
await using var entryStream = await zipReader.OpenEntryStreamAsync(cancellationToken).ConfigureAwait(false);
int read;
FlushResult flushed;
do
Expand Down
Loading
Loading