Skip to content

Commit

Permalink
CodeQA
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Oct 13, 2024
1 parent e8b7cfb commit b7f4c73
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public ZenlessCache(UIElement parentUI, IGameVersionCheck gameVersionManager, Ze
public ZenlessCache AsBaseType() => this;

public async Task StartUpdateRoutine(bool showInteractivePrompt = false)
=> await base.StartRepairRoutine(showInteractivePrompt);
=> await StartRepairRoutine(showInteractivePrompt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ZenlessManifestInterceptStream : Stream
internal ZenlessManifestInterceptStream(string? filePath, Stream stream)
{
innerStream = stream;
if (!string.IsNullOrWhiteSpace(filePath))
if (!string.IsNullOrWhiteSpace(filePath) && stream != null)

Check warning on line 34 in CollapseLauncher/Classes/RepairManagement/Zenless/ZenlessRepair.Extensions.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Expression is always 'true' or 'false' according to nullable reference types' annotations

Expression is always true according to nullable reference types' annotations

Check warning

Code scanning / QDNET

Expression is always 'true' or 'false' according to nullable reference types' annotations Warning

Expression is always true according to nullable reference types' annotations
{
string? filePathDir = Path.GetDirectoryName(filePath);
if (!string.IsNullOrEmpty(filePathDir) && !Directory.Exists(filePathDir))
Expand Down Expand Up @@ -184,11 +184,8 @@ public override void Write(byte[] buffer, int offset, int count)

public override async ValueTask DisposeAsync()
{
if (innerStream != null)
await innerStream.DisposeAsync();

if (redirectStream != null)
await redirectStream.DisposeAsync();
await innerStream.DisposeAsync();
await redirectStream.DisposeAsync();
}

protected override void Dispose(bool disposing)
Expand Down Expand Up @@ -287,7 +284,7 @@ internal static async IAsyncEnumerable<PkgVersionProperties> RegisterSleepyFileI
private static FilePropertiesRemote? ReturnCategorizedYieldValue(Dictionary<string, FilePropertiesRemote> hashSet, List<FilePropertiesRemote> assetIndex, PkgVersionProperties asset, string baseLocalPath, string baseUrl, string? alternativeUrlIfNonPatch = null)
{
FilePropertiesRemote asRemoteProperty = GetNormalizedFilePropertyTypeBased(
asset.isPatch || string.IsNullOrEmpty(alternativeUrlIfNonPatch) ? baseUrl : alternativeUrlIfNonPatch!,
asset.isPatch || string.IsNullOrEmpty(alternativeUrlIfNonPatch) ? baseUrl : alternativeUrlIfNonPatch,
baseLocalPath,
asset.remoteName,
asset.fileSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,32 @@ private async Task GetPrimaryManifest(DownloadClient downloadClient, Dictionary<
string urlIndex = string.Format(LauncherConfig.AppGameRepairIndexURLPrefix, _gameVersionManager.GamePreset.ProfileName, _gameVersion.VersionString) + ".binv2";

// Start downloading asset index using FallbackCDNUtil and return its stream
await using BridgedNetworkStream stream = await FallbackCDNUtil.TryGetCDNFallbackStream(urlIndex, token);
await Task.Run(() =>
await using (BridgedNetworkStream stream = await FallbackCDNUtil.TryGetCDNFallbackStream(urlIndex, token))
{
if (stream != null)
await Task.Run(() =>
{
// Deserialize asset index and set it to list
AssetIndexV2 parserTool = new AssetIndexV2();
pkgVersion = parserTool.Deserialize(stream, out DateTime timestamp);
}
if (stream != null)

Check warning on line 117 in CollapseLauncher/Classes/RepairManagement/Zenless/ZenlessRepair.Fetch.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Access to disposed captured variable

Captured variable is disposed in the outer scope

Check warning

Code scanning / QDNET

Access to disposed captured variable Warning

Captured variable is disposed in the outer scope
{
// Deserialize asset index and set it to list
AssetIndexV2 parserTool = new AssetIndexV2();
pkgVersion = parserTool.Deserialize(stream, out DateTime timestamp);

Check warning on line 121 in CollapseLauncher/Classes/RepairManagement/Zenless/ZenlessRepair.Fetch.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Access to disposed captured variable

Captured variable is disposed in the outer scope

Check warning

Code scanning / QDNET

Access to disposed captured variable Warning

Captured variable is disposed in the outer scope
Logger.LogWriteLine($"Asset index timestamp: {timestamp}", LogType.Default, true);
}
// Convert the pkg version list to asset index
foreach (FilePropertiesRemote entry in pkgVersion.RegisterMainCategorizedAssetsToHashSet(assetIndex, hashSet, _gamePath, _gameRepoURL))
{
// If entry is null (means, an existing entry has been overwritten), then next
if (entry == null)
continue;
// Convert the pkg version list to asset index
foreach (FilePropertiesRemote entry in pkgVersion.RegisterMainCategorizedAssetsToHashSet(assetIndex, hashSet, _gamePath, _gameRepoURL))
{
// If entry is null (means, an existing entry has been overwritten), then next
if (entry == null)
continue;
assetIndex.Add(entry);
}
assetIndex.Add(entry);
}
// Clear the pkg version list
pkgVersion.Clear();
}).ConfigureAwait(false);
// Clear the pkg version list
pkgVersion.Clear();
}).ConfigureAwait(false);
}
}

private async Task<Dictionary<string, string>> FetchMetadata(CancellationToken token)
Expand Down

0 comments on commit b7f4c73

Please sign in to comment.