Skip to content

Commit

Permalink
minor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Nov 8, 2023
1 parent 814c32b commit e419b4a
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ProjBobcat/ProjBobcat/Class/Model/AssetObjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AssetObjectModel
/// Asset Objects集合
/// </summary>
[JsonPropertyName("objects")]
public Dictionary<string, AssetFileInfo> Objects { get; set; }
public IReadOnlyDictionary<string, AssetFileInfo> Objects { get; set; }
}

[JsonSerializable(typeof(AssetObjectModel))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CurseForgeAddonInfo
[JsonPropertyName("gameId")] public int GameId { get; set; }

[JsonPropertyName("summary")] public string Summary { get; set; }
[JsonPropertyName("links")] public Dictionary<string, string> Links { get; set; }
[JsonPropertyName("links")] public IReadOnlyDictionary<string, string> Links { get; set; }

[JsonPropertyName("defaultFileId")] public int DefaultFileId { get; set; }
[JsonPropertyName("releaseType")] public int ReleaseType { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class FabricModInfoModel

[JsonPropertyName("environment")] public string Environment { get; set; }

[JsonPropertyName("entrypoints")] public Dictionary<string, string[]> Entrypoints { get; set; }
[JsonPropertyName("entrypoints")] public IReadOnlyDictionary<string, string[]> Entrypoints { get; set; }

[JsonPropertyName("custom")] public Custom Custom { get; set; }

[JsonPropertyName("depends")] public Dictionary<string, string> Depends { get; set; }
[JsonPropertyName("depends")] public IReadOnlyDictionary<string, string> Depends { get; set; }

[JsonPropertyName("recommends")] public Dictionary<string, string> Recommends { get; set; }
[JsonPropertyName("recommends")] public IReadOnlyDictionary<string, string> Recommends { get; set; }

[JsonPropertyName("name")] public string Name { get; set; }

Expand All @@ -46,7 +46,7 @@ public class FabricModInfoModel

[JsonPropertyName("authors")] public string[] Authors { get; set; }

[JsonPropertyName("contacts")] public Dictionary<string, string> Contacts { get; set; }
[JsonPropertyName("contacts")] public IReadOnlyDictionary<string, string> Contacts { get; set; }

[JsonPropertyName("jars")] public FabricFileInfo[] Jars { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ForgeInstallProfileProcessor

[JsonPropertyName("args")] public string[] Arguments { get; set; }

[JsonPropertyName("outputs")] public Dictionary<string, string> Outputs { get; set; }
[JsonPropertyName("outputs")] public IReadOnlyDictionary<string, string> Outputs { get; set; }
}

public class ForgeInstallProfile
Expand All @@ -45,7 +45,7 @@ public class ForgeInstallProfile

[JsonPropertyName("welcome")] public string Welcome { get; set; }

[JsonPropertyName("data")] public Dictionary<string, ForgeInstallProfileData> Data { get; set; }
[JsonPropertyName("data")] public IReadOnlyDictionary<string, ForgeInstallProfileData> Data { get; set; }

[JsonPropertyName("processors")] public ForgeInstallProfileProcessor[] Processors { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace ProjBobcat.Class.Model.MicrosoftAuth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ModrinthModPackFileModel
{
[JsonPropertyName("path")] public string? Path { get; set; }

[JsonPropertyName("hashes")] public Dictionary<string, string> Hashes { get; set; }
[JsonPropertyName("hashes")] public IReadOnlyDictionary<string, string> Hashes { get; set; }

[JsonPropertyName("downloads")] public string[] Downloads { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ModrinthModPackIndexModel

[JsonPropertyName("files")] public ModrinthModPackFileModel[] Files { get; set; }

[JsonPropertyName("dependencies")] public Dictionary<string, string> Dependencies { get; set; }
[JsonPropertyName("dependencies")] public IReadOnlyDictionary<string, string> Dependencies { get; set; }
}

[JsonSerializable(typeof(ModrinthModPackIndexModel))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ProjBobcat.Class.Model.Modrinth;

public class ModrinthFileInfo
{
[JsonPropertyName("hashes")] public Dictionary<string, string> Hashes { get; set; }
[JsonPropertyName("hashes")] public IReadOnlyDictionary<string, string> Hashes { get; set; }

[JsonPropertyName("url")] public string Url { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class UserProfilePropertyValue
[JsonPropertyName("timestamp")] public long Timestamp { get; set; }
[JsonPropertyName("profileId")] public string ProfileId { get; set; }
[JsonPropertyName("profileName")] public string ProfileName { get; set; }
[JsonPropertyName("textures")] public Dictionary<string, UrlModel> Textures { get; set; }
[JsonPropertyName("textures")] public IReadOnlyDictionary<string, UrlModel> Textures { get; set; }
}

[JsonSerializable(typeof(UserProfilePropertyValue))]
Expand Down
4 changes: 2 additions & 2 deletions ProjBobcat/ProjBobcat/Class/Model/RawVersionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class Extract
public class Downloads
{
[JsonPropertyName("artifact")] public FileInfo? Artifact { get; set; }
[JsonPropertyName("classifiers")] public Dictionary<string, FileInfo> Classifiers { get; set; }
[JsonPropertyName("classifiers")] public IReadOnlyDictionary<string, FileInfo> Classifiers { get; set; }
}

public class Library
Expand All @@ -86,7 +86,7 @@ public class Library

[JsonPropertyName("extract")] public Extract Extract { get; set; }

[JsonPropertyName("natives")] public Dictionary<string, string> Natives { get; set; }
[JsonPropertyName("natives")] public IReadOnlyDictionary<string, string> Natives { get; set; }

[JsonPropertyName("rules")] public JvmRules[] Rules { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public class PlayerTextureInfoModel

[JsonPropertyName("profileName")] public string ProfileName { get; set; }

[JsonPropertyName("textures")] public Dictionary<string, TextureInfoModel> Textures { get; set; }
[JsonPropertyName("textures")] public IReadOnlyDictionary<string, TextureInfoModel> Textures { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public event EventHandler<DownloadFileCompletedEventArgs> DownloadFileCompletedE
async Task ReceiveGameResourceTask(IAsyncEnumerable<IGameResource> asyncEnumerable)
{
var count = 0UL;
var refreshCounter = 0;

await foreach (var element in asyncEnumerable)
{
Expand All @@ -133,6 +134,13 @@ async Task ReceiveGameResourceTask(IAsyncEnumerable<IGameResource> asyncEnumerab
});

await gameResourceTransBlock.SendAsync(element);
refreshCounter++;

if (refreshCounter % 10 == 0)
{
Interlocked.Add(ref _needToDownload, count);
count = 0;
}
}

Interlocked.Add(ref _needToDownload, count);
Expand All @@ -141,7 +149,7 @@ async Task ReceiveGameResourceTask(IAsyncEnumerable<IGameResource> asyncEnumerab
var chunks = ResourceInfoResolvers.Chunk(MaxDegreeOfParallelism).ToImmutableArray();
foreach (var chunk in chunks)
{
var tasks = new Task[chunk.Length];
var tasks = new Task[chunk.Length * 2];

for (var i = 0; i < chunk.Length; i++)
{
Expand Down

0 comments on commit e419b4a

Please sign in to comment.