Skip to content

Commit

Permalink
Preview 1.82.4 Release (#617)
Browse files Browse the repository at this point in the history
# What's new? - 1.82.4
- **[Fix]** (GI/SR/ZZZ Repair) Fixed Quick Repair does not check for
file size matching, by @neon-nyan & @bagusnl
- **[Fix]** Tray icon not appearing in any builds before Windows 11 21H2
(inc W10), by @shatyuka & @bagusnl
- **[Imp]** Sentry enhancements, by @bagusnl 
  - Disable error collection in debug builds
  - Add current loaded game location and CDN preference to breadcrumbs
- Add a way to enable debug logging via console by adding "DEBUG_SENTRY"
env var and setting it to true
- **[Imp]** Update dependencies, by @bagusnl 
- **[Imp]** Save last known working CDN to config, by @bagusnl 
- **[Fix]** ArgumentNull crash on StartCarouselAutoScroll, by @bagusnl 

<details>
  <summary>Changelog Prefixes</summary>
  
  ```
    **[New]**
    **[Imp]**
    **[Fix]**
    **[Loc]**
    **[Doc]**
  ```

</details>
  • Loading branch information
Cryotechnic authored Dec 8, 2024
2 parents 3581cb4 + 0c76376 commit 2c06d09
Show file tree
Hide file tree
Showing 34 changed files with 352 additions and 206 deletions.
58 changes: 52 additions & 6 deletions .github/workflows/qodana-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,72 @@ on:

jobs:
qodana:
runs-on: ubuntu-latest
runs-on: windows-latest
strategy:
matrix:
configuration: [Release] # No need to distribute Debug builds
platform: [x64]
framework: [net9.0-windows10.0.22621.0]

env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
DOTNET_INSTALL_DIR: '.\.dotnet'
DOTNET_VERSION: '9.x'
DOTNET_QUALITY: 'ga'
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

permissions:
actions: read
contents: write
pull-requests: write
checks: write
security-events: write

steps:
- uses: actions/checkout@v4.1.5
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
submodules: recursive # many many submodules

- name: 'Qodana Scan'
uses: JetBrains/qodana-action@latest
# - name: Install winget
# uses: Cyberboss/install-winget@v1

# - name: Install Qodana CLI
# uses: crazy-max/ghaction-chocolatey@v3
# with:
# args: install qodana --pre --confirm

# - name: Verify Qodana
# run: |
# Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
# refreshenv
# qodana --version

- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: ${{ env.DOTNET_QUALITY }}
cache: true
cache-dependency-path: CollapseLauncher/packages.lock.json

# - name: Qodana Scan
# run: |
# Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
# refreshenv
# qodana scan --ide QDNET-EAP -o ${{ runner.temp }}\qodana\results --cache-dir ${{ runner.temp }}\qodana\cache

- name: Qodana Scan
uses: JetBrains/qodana-action@next
continue-on-error: true
with:
pr-mode: false
args: --ide,QDNET-EAP
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} # read the steps about it below
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

- uses: github/codeql-action/upload-sarif@v3
if: always()
continue-on-error: true
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
2 changes: 1 addition & 1 deletion CollapseLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Hi3Helper;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.Region;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.Enums;
using Hi3Helper.Win32.Native.LibraryImport;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
Expand Down
7 changes: 4 additions & 3 deletions CollapseLauncher/Classes/GamePropertyVault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Hi3Helper;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.ClassStruct;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.ManagedTools;
using Microsoft.UI.Xaml;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -78,6 +78,7 @@ internal GamePresetProperty(UIElement uiElementParent, RegionResourceProp apiRes

SentryHelper.CurrentGameCategory = _GameVersion.GameName;
SentryHelper.CurrentGameRegion = _GameVersion.GameRegion;
SentryHelper.CurrentGameLocation = _GameVersion.GameDirPath;
SentryHelper.CurrentGameInstalled = _GameVersion.IsGameInstalled();
SentryHelper.CurrentGameUpdated = _GameVersion.IsGameVersionMatch();
SentryHelper.CurrentGameHasPreload = _GameVersion.IsGameHasPreload();
Expand Down Expand Up @@ -117,7 +118,7 @@ internal string _GameExecutableNameWithoutExtension

internal bool IsGameRunning
{
get => PInvoke.IsProcessExist(_GameExecutableName, out _, out _, Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName), ILoggerHelper.GetILogger());
get => ProcessChecker.IsProcessExist(_GameExecutableName, out _, out _, Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName), ILoggerHelper.GetILogger());
}

#nullable enable
Expand All @@ -136,7 +137,7 @@ internal bool IsGameRunning
Process process = processArr[i];
int processId = process.Id;

string? processPath = PInvoke.GetProcessPathByProcessId(processId, ILoggerHelper.GetILogger());
string? processPath = ProcessChecker.GetProcessPathByProcessId(processId, ILoggerHelper.GetILogger());
string expectedProcessPath = Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName);
if (string.IsNullOrEmpty(processPath) || !expectedProcessPath.Equals(processPath, StringComparison.OrdinalIgnoreCase)
|| process.MainWindowHandle == IntPtr.Zero)
Expand Down
5 changes: 3 additions & 2 deletions CollapseLauncher/Classes/Helper/WindowUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.Region;
using Hi3Helper.Win32.FileDialogCOM;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.Enums;
using Hi3Helper.Win32.Native.LibraryImport;
using Hi3Helper.Win32.Native.ManagedTools;
using Hi3Helper.Win32.Native.Structs;
using Hi3Helper.Win32.Screen;
using Microsoft.Graphics.Display;
Expand Down Expand Up @@ -557,7 +558,7 @@ internal static void SetWindowTitlebarIcon(nint smallIconPtr, nint largeIconPtr)
return;
}

PInvoke.SetWindowIcon(CurrentWindowPtr, smallIconPtr, largeIconPtr);
Windowing.SetWindowIcon(CurrentWindowPtr, smallIconPtr, largeIconPtr);
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion CollapseLauncher/Classes/Properties/InnerLauncherConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CollapseLauncher.Pages;
using Hi3Helper;
using Hi3Helper.Shared.ClassStruct;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.LibraryImport;
using Microsoft.UI.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down
19 changes: 15 additions & 4 deletions CollapseLauncher/Classes/RegionManagement/FallbackCDNUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public static async Task DownloadCDNFallbackContent(DownloadClient downloadClien
{
// Get the preferred CDN first and try get the content
CDNURLProperty preferredCDN = GetPreferredCDN();
SentryHelper.AppCdnOption = preferredCDN.Name;
bool isSuccess = await TryGetCDNContent(preferredCDN, downloadClient, outputPath, relativeURL, parallelThread, token);

// If successful, then return
Expand All @@ -186,7 +187,12 @@ public static async Task DownloadCDNFallbackContent(DownloadClient downloadClien
isSuccess = await TryGetCDNContent(fallbackCDN, downloadClient, outputPath, relativeURL, parallelThread, token);

// If successful, then return
if (isSuccess) return;
if (isSuccess)
{
var i = CDNList.IndexOf(fallbackCDN);
SetAndSaveConfigValue("CurrentCDN", i);
return;
}
}

// If all of them failed, then throw an exception
Expand Down Expand Up @@ -219,7 +225,12 @@ public static async Task DownloadCDNFallbackContent(DownloadClient downloadClien
isSuccess = await TryGetCDNContent(fallbackCDN, downloadClient, outputStream, relativeURL, token);

// If successful, then return
if (isSuccess) return;
if (isSuccess)
{
var i = CDNList.IndexOf(fallbackCDN);
SetAndSaveConfigValue("CurrentCDN", i);
return;
}
}

// If all of them failed, then throw an exception
Expand Down Expand Up @@ -433,11 +444,11 @@ private static async ValueTask<CDNUtilHTTPStatus> TryGetURLStatus(CDNURLProperty
return CDNUtilHTTPStatus.CreateInitializationError();
}
}

public static CDNURLProperty GetPreferredCDN()
{
// Get the CurrentCDN index
int cdnIndex = GetAppConfigValue("CurrentCDN").ToInt();
var cdnIndex = GetAppConfigValue("CurrentCDN").ToInt();

// Fallback to the first CDN if index < 0 or > length of the list
if (cdnIndex < 0 || cdnIndex > CDNList.Count - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

using Hi3Helper;
using Hi3Helper.SentryHelper;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.Enums;
using Hi3Helper.Win32.Native.LibraryImport;
using Microsoft.Win32;
using System;
using System.ComponentModel;
Expand Down
9 changes: 6 additions & 3 deletions CollapseLauncher/Classes/RepairManagement/Genshin/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Hi3Helper.Data;
using Hi3Helper.EncTool.Parser.AssetIndex;
using Hi3Helper.SentryHelper;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.ManagedTools;
using System;
using System.Buffers;
using System.Collections.Concurrent;
Expand Down Expand Up @@ -49,7 +49,7 @@ private async Task Check(List<PkgVersionProperties> assetIndex, CancellationToke
try
{
var threadCount = _threadCount;
var isSsd = PInvoke.IsDriveSsd(_gameStreamingAssetsPath, ILoggerHelper.GetILogger());
var isSsd = DriveTypeChecker.IsDriveSsd(_gameStreamingAssetsPath, ILoggerHelper.GetILogger());
if (!isSsd)
{
threadCount = 1;
Expand Down Expand Up @@ -292,10 +292,13 @@ async ValueTask<bool> IsFileMatched(Action<bool> storeAsStreaming, Action<bool>

async ValueTask<bool> IsFileHashMatch(FileInfo fileInfo, ReadOnlyMemory<byte> hashToCompare, CancellationToken cancelToken)
{
if (_useFastMethod) return true; // Skip the hash calculation if the fast method is enabled
// Refresh the fileInfo
fileInfo.Refresh();

if (fileInfo.Length != asset.fileSize) return false; // Skip the hash calculation if the file size is different

if (_useFastMethod) return true; // Skip the hash calculation if the fast method is enabled

// Try to get filestream
await using FileStream fileStream = await fileInfo.NaivelyOpenFileStreamAsync(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

Expand Down
62 changes: 38 additions & 24 deletions CollapseLauncher/Classes/RepairManagement/StarRail/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
using Hi3Helper.Data;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.ClassStruct;
using Hi3Helper.Win32.Native;
using Hi3Helper.Win32.Native.LibraryImport;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -141,33 +142,20 @@ private async ValueTask CheckGenericAssetType(FilePropertiesRemote asset, List<F
// Check if the file exist or has unmatched size
if (!fileInfo.Exists)
{
// Update the total progress and found counter
_progressAllSizeFound += asset.S;
_progressAllCountFound++;

// Set the per size progress
_progressPerFileSizeCurrent = asset.S;

// Increment the total current progress
_progressAllSizeCurrent += asset.S;

Dispatch(() => AssetEntry.Add(
new AssetProperty<RepairAssetType>(
Path.GetFileName(asset.N),
ConvertRepairAssetTypeEnum(asset.FT),
Path.GetDirectoryName(asset.N),
asset.S,
null,
null
)
));
targetAssetIndex.Add(asset);

AddIndex();
LogWriteLine($"File [T: {asset.FT}]: {asset.N} is not found", LogType.Warning, true);

return;
}

if (fileInfo.Length != asset.S)
{
if (fileInfo.Name.Contains("pkg_version")) return;
AddIndex();
LogWriteLine($"File [T: {asset.FT}]: {asset.N} has unmatched size " +
$"(Local: {fileInfo.Length} <=> Remote: {asset.S}",
LogType.Warning, true);
}

// Skip CRC check if fast method is used
if (_useFastMethod)
{
Expand Down Expand Up @@ -203,6 +191,32 @@ private async ValueTask CheckGenericAssetType(FilePropertiesRemote asset, List<F

LogWriteLine($"File [T: {asset.FT}]: {asset.N} is broken! Index CRC: {asset.CRC} <--> File CRC: {HexTool.BytesToHexUnsafe(localCRC)}", LogType.Warning, true);
}
return;

void AddIndex()
{
// Update the total progress and found counter
_progressAllSizeFound += asset.S;
_progressAllCountFound++;

// Set the per size progress
_progressPerFileSizeCurrent = asset.S;

// Increment the total current progress
_progressAllSizeCurrent += asset.S;

Dispatch(() => AssetEntry.Add(
new AssetProperty<RepairAssetType>(
Path.GetFileName(asset.N),
ConvertRepairAssetTypeEnum(asset.FT),
Path.GetDirectoryName(asset.N),
asset.S,
null,
null
)
));
targetAssetIndex.Add(asset);
}
}

private async ValueTask CheckAssetType(FilePropertiesRemote asset, List<FilePropertiesRemote> targetAssetIndex, CancellationToken token)
Expand Down
Loading

0 comments on commit 2c06d09

Please sign in to comment.