Skip to content

Commit 9daa48a

Browse files
committed
fixup
1 parent 0ed43bd commit 9daa48a

16 files changed

Lines changed: 57 additions & 119 deletions

MaiChartManager/Browser.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ private void webView21_CoreWebView2InitializationCompleted(object sender, CoreWe
8989
webView21.CoreWebView2.PermissionRequested += WebViewHelper.OnPermissionRequested;
9090
webView21.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
9191
webView21.CoreWebView2.WebMessageReceived += OnWebMessageReceived;
92+
93+
#if DEBUG
94+
WindowState = FormWindowState.Minimized;
95+
#endif
9296
}
9397

9498
private async void CoreWebView2_NewWindowRequested(object? sender, CoreWebView2NewWindowRequestedEventArgs e)

MaiChartManager/Controllers/App/OobeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public IActionResult DeleteGamePathHistory([FromBody] string path)
6969
}
7070

7171
[HttpPost]
72-
public void InitializeGameData()
72+
public async Task InitializeGameData()
7373
{
74-
settings.InitializeGameData();
74+
await settings.InitializeGameData();
7575
}
7676

7777
[HttpGet]

MaiChartManager/Controllers/AssetDir/AssetDirController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void PutAssetDirTxtValue([FromBody] PutAssetDirTxtValueRequest req)
103103
}
104104

105105
[HttpPost]
106-
public void RequestLocalImportDir()
106+
public async Task RequestLocalImportDir()
107107
{
108108
var dialog = new FolderBrowserDialog
109109
{
@@ -133,7 +133,7 @@ public void RequestLocalImportDir()
133133
var dest = Path.Combine(StaticSettings.StreamingAssets, destName);
134134
logger.LogInformation("Src: {src} Dest: {dest}", src, dest);
135135
FileSystem.CopyDirectory(src, dest, UIOption.AllDialogs);
136-
settings.RescanAll();
136+
await settings.RescanAll();
137137
}
138138

139139
public record UploadAssetDirResult(string DirName);
@@ -181,7 +181,7 @@ public async Task<UploadAssetDirResult> UploadAssetDir(string? destName)
181181
section = await reader.ReadNextSectionAsync();
182182
}
183183

184-
settings.RescanAll();
184+
await settings.RescanAll();
185185

186186
return new UploadAssetDirResult(destName);
187187
}

MaiChartManager/Controllers/AssetDir/MusicListController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public IEnumerable<MusicXmlWithABJacket> GetMusicList()
1414
}
1515

1616
[HttpPost]
17-
public void ReloadAll()
17+
public async Task ReloadAll()
1818
{
19-
settings.RescanAll();
19+
await settings.RescanAll();
2020
}
2121
}

MaiChartManager/Controllers/Mod/ConfigurationController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public ConfigurationController(StaticSettings settings, ILogger<ConfigurationCon
2626
}
2727

2828
[HttpGet]
29-
public AquaMaiConfigDto.ConfigDto GetAquaMaiConfig(bool forceDefault = false, bool skipSignatureCheck = false)
29+
public async Task<AquaMaiConfigDto.ConfigDto> GetAquaMaiConfig(bool forceDefault = false, bool skipSignatureCheck = false)
3030
{
31-
var dllPath = modConfigService.GetAquaMaiDllPath();
31+
var dllPath = await modConfigService.GetAquaMaiDllPath();
3232
Dictionary<string, string[]>? configSort = null;
3333
using (var stream = new FileStream(dllPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
3434
{
@@ -43,7 +43,7 @@ public AquaMaiConfigDto.ConfigDto GetAquaMaiConfig(bool forceDefault = false, bo
4343
}
4444
}
4545
var shouldSkipSignatureCheck = skipSignatureCheck || !string.Equals(dllPath, ModPaths.AquaMaiDllInstalledPath, StringComparison.OrdinalIgnoreCase);
46-
var config = modConfigService.GetCurrentAquaMaiConfig(forceDefault, shouldSkipSignatureCheck);
46+
var config = await modConfigService.GetCurrentAquaMaiConfig(forceDefault, shouldSkipSignatureCheck);
4747
return new AquaMaiConfigDto.ConfigDto(
4848
config.ReflectionManager.Sections.Select(section =>
4949
{
@@ -59,7 +59,7 @@ public AquaMaiConfigDto.ConfigDto GetAquaMaiConfig(bool forceDefault = false, bo
5959
[HttpPut]
6060
public async Task SetAquaMaiConfig(AquaMaiConfigDto.ConfigSaveDto config)
6161
{
62-
var dllPath = modConfigService.GetAquaMaiDllPath();
62+
var dllPath = await modConfigService.GetAquaMaiDllPath();
6363
var jsonOptions = new JsonSerializerOptions();
6464
jsonOptions.Converters.Add(new JsonStringEnumConverter());
6565

MaiChartManager/Controllers/Mod/ModConfigService.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void CheckConfigApiVersion(HeadlessConfigInterface configInterface)
3636
}
3737
}
3838

39-
public string GetAquaMaiDllPath()
39+
public async Task<string> GetAquaMaiDllPath(CancellationToken ct = default)
4040
{
4141
var muModInstalled = _muModService.IsMuModInstalled();
4242
var aquaMaiInstalled = File.Exists(ModPaths.AquaMaiDllInstalledPath);
@@ -45,6 +45,11 @@ public string GetAquaMaiDllPath()
4545
{
4646
var cachePath = _muModService.GetResolvedCachePath();
4747
if (!File.Exists(cachePath))
48+
{
49+
// 缓存不存在,下载(DLL 不大,卡一下没事)
50+
await _muModService.EnsureCache(ct);
51+
}
52+
if (!File.Exists(cachePath))
4853
{
4954
throw new AquaMaiNotInstalledException();
5055
}
@@ -60,9 +65,9 @@ public string GetAquaMaiDllPath()
6065
throw new AquaMaiNotInstalledException();
6166
}
6267

63-
public IConfig GetCurrentAquaMaiConfig(bool forceDefault = false, bool skipSignatureCheck = false)
68+
public async Task<IConfig> GetCurrentAquaMaiConfig(bool forceDefault = false, bool skipSignatureCheck = false, CancellationToken ct = default)
6469
{
65-
var dllPath = GetAquaMaiDllPath();
70+
var dllPath = await GetAquaMaiDllPath(ct);
6671

6772
var binary = File.ReadAllBytes(dllPath);
6873
if (!skipSignatureCheck)

MaiChartManager/Controllers/Mod/MuModService.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,12 @@ public string GetResolvedCachePath()
8585
var config = ReadConfig();
8686
var rawPath = string.IsNullOrWhiteSpace(config.CachePath) ? DefaultCacheRelativePath : config.CachePath;
8787

88-
if (ContainsParentTraversal(rawPath))
89-
{
90-
throw new InvalidOperationException("MuMod cache path cannot contain '..'");
91-
}
92-
9388
var expandedPath = Environment.ExpandEnvironmentVariables(rawPath.Trim());
9489
var candidate = Path.IsPathRooted(expandedPath)
9590
? expandedPath
9691
: Path.Combine(StaticSettings.GamePath, expandedPath);
9792

98-
var fullPath = Path.GetFullPath(candidate);
99-
var gameRoot = Path.GetFullPath(StaticSettings.GamePath);
100-
if (!IsPathInsideRoot(fullPath, gameRoot))
101-
{
102-
throw new InvalidOperationException($"MuMod cache path escapes game directory: {fullPath}");
103-
}
104-
105-
return fullPath;
93+
return Path.GetFullPath(candidate);
10694
}
10795

10896
public async Task<EnsureCacheResult> EnsureCache(CancellationToken ct = default)
@@ -189,19 +177,6 @@ public bool IsMuModInstalled()
189177
return File.Exists(ModPaths.MuModDllInstalledPath) ? ReadProductVersion(ModPaths.MuModDllInstalledPath) : null;
190178
}
191179

192-
private static bool ContainsParentTraversal(string path)
193-
{
194-
var segments = path.Split([Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar], StringSplitOptions.RemoveEmptyEntries);
195-
return segments.Any(segment => segment == "..");
196-
}
197-
198-
private static bool IsPathInsideRoot(string fullPath, string rootPath)
199-
{
200-
var normalizedRoot = rootPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + Path.DirectorySeparatorChar;
201-
return fullPath.StartsWith(normalizedRoot, StringComparison.OrdinalIgnoreCase)
202-
|| string.Equals(fullPath, rootPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), StringComparison.OrdinalIgnoreCase);
203-
}
204-
205180
private static string ResolveApiType(string channel)
206181
{
207182
return channel switch

MaiChartManager/Controllers/Music/MusicTransferController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ private void DeleteIfExists(params string[] path)
443443
}
444444

445445
[HttpPost]
446-
public void ModifyId(int id, [FromBody] int newId, string assetDir)
446+
public async Task ModifyId(int id, [FromBody] int newId, string assetDir)
447447
{
448448
if (IapManager.License != IapManager.LicenseStatus.Active) return;
449449
var music = settings.GetMusic(id, assetDir);
@@ -530,7 +530,7 @@ public void ModifyId(int id, [FromBody] int newId, string assetDir)
530530
FileSystem.MoveDirectory(oldMusicDir, newMusicDir, UIOption.OnlyErrorDialogs);
531531

532532
// rescan all
533-
settings.RescanAll();
533+
await settings.RescanAll();
534534
}
535535

536536
[HttpGet]

MaiChartManager/Front/src/locales/en.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ mod:
291291
other: Other
292292
needEnableOption: Need to enable this option
293293
unsupportedType: 'Unsupported type: {type}'
294-
notInstalledTitle: AquaMai Not Installed
295-
notInstalledWarningMessage: >-
296-
MelonLoader or AquaMai is not installed, music jackets won't load in game.
297-
Click Mod Management to install
298294
dontShowAgain: Don't show again
299295
versionNotFound: Version not found
300296
installFailed: Failed to install AquaMai, files may be in use?
@@ -304,7 +300,8 @@ mod:
304300
versionTooLow: AquaMai version too low, please update to 1.6.0 or above
305301
installed: Installed
306302
installedVersion: Installed
307-
availableVersion: Available
303+
availableVersion: Latest
304+
loaded: Loaded
308305
killGameProcess: Kill Game Process
309306
needInstallOrUpdate: AquaMai not installed or needs update
310307
adxHid:
@@ -442,7 +439,7 @@ mod:
442439
fastChannel: "Fast Channel"
443440
mumod: "MuMod"
444441
mumodDesc: "Auto-update Loader"
445-
mumodInstalled: "MuMod Installed"
442+
mumodInstalled: "Installed"
446443
mumodChannel: "Update Channel"
447444
mumodChannelSlow: "Stable"
448445
mumodChannelFast: "Fast"

MaiChartManager/Front/src/locales/zh-TW.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ mod:
269269
other: 其他
270270
needEnableOption: 需要開啟此選項
271271
unsupportedType: '不支援的類型: {type}'
272-
notInstalledTitle: 沒有安裝 AquaMai
273-
notInstalledWarningMessage: 沒有安裝 MelonLoader 或者 AquaMai,在遊戲中將無法載入歌曲封面。請點擊 Mod 管理來安裝
274272
dontShowAgain: 不再提示
275273
versionNotFound: 未找到對應版本
276274
installFailed: 安裝 AquaMai 失敗,檔案可能被占用了?
@@ -280,7 +278,8 @@ mod:
280278
versionTooLow: AquaMai 版本過低,請更新到 1.6.0 以上
281279
installed: 已安裝
282280
installedVersion: 已安裝
283-
availableVersion: 可安裝
281+
availableVersion: 最新
282+
loaded: 已載入
284283
killGameProcess: 關閉遊戲處理程序
285284
needInstallOrUpdate: AquaMai 未安裝或需要更新
286285
adxHid:
@@ -403,7 +402,7 @@ mod:
403402
fastChannel: "快速通道"
404403
mumod: "MuMod"
405404
mumodDesc: "自動更新載入器"
406-
mumodInstalled: "MuMod 已安裝"
405+
mumodInstalled: "已安裝"
407406
mumodChannel: "更新通道"
408407
mumodChannelSlow: "穩定"
409408
mumodChannelFast: "快速"

0 commit comments

Comments
 (0)