chore: 增加更新时解压更新包失败日志,增加解压失败解决方案

This commit is contained in:
uye
2024-06-16 19:30:33 +08:00
parent 718d2d07fa
commit 8cc725f3e8
7 changed files with 46 additions and 11 deletions

View File

@@ -593,6 +593,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
<system:String x:Key="ErrorDetails">Details</system:String>
<system:String x:Key="ErrorSolution">Solution</system:String>
<system:String x:Key="ErrorSolutionCrash">Please refer to the documentation: 「FAQ - Crashes」 to solve.</system:String>
<system:String x:Key="ErrorSolutionUpdatePackageExtractionFailed">Failed to extract the update package. Please try to manually extract the update package in the root directory.</system:String>
<system:String x:Key="ErrorSolutionReplaceAdb">Please retry after shutting down the emulator and killing ADB. Otherwise restart your computer, then run MAA as administrator without opening the emulator, finally retry it.</system:String>
<system:String x:Key="ErrorSolutionFailedToMove">The file is occupied, please restart the computer and try again.</system:String>
<system:String x:Key="ErrorSolutionSelectDefaultBrowser">Open link failure, please go to "Windows Settings" and select the default browser.</system:String>

View File

@@ -590,6 +590,7 @@
<system:String x:Key="ErrorDetails">詳細情報</system:String>
<system:String x:Key="ErrorSolution">解決策</system:String>
<system:String x:Key="ErrorSolutionCrash">ドキュメント「よくある問題 - クラッシュ」を参照してください。</system:String>
<system:String x:Key="ErrorSolutionUpdatePackageExtractionFailed">アップデートパッケージの解凍に失敗しました。ルートディレクトリにあるアップデートパッケージを手動で解凍してみてください。</system:String>
<system:String x:Key="ErrorSolutionReplaceAdb">エミュレータとADBを閉じるか、コンピューターを再起動してから、管理者権限でMAAを開いて操作してください。</system:String>
<system:String x:Key="ErrorSolutionFailedToMove">ファイルが占有されています。コンピュータを再起動して再試行してください。</system:String>
<system:String x:Key="ErrorSolutionSelectDefaultBrowser">リンクを開けませんでした。Windows 設定に移動してデフォルトのブラウザを選択してください。</system:String>

View File

@@ -590,6 +590,7 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.</system:String>
<system:String x:Key="ErrorDetails">세부 정보</system:String>
<system:String x:Key="ErrorSolution">해결 방법</system:String>
<system:String x:Key="ErrorSolutionCrash">FAQ 문서의 크래시 관련 문단을 참고하세요.</system:String>
<system:String x:Key="ErrorSolutionUpdatePackageExtractionFailed">업데이트 패키지 압축 해제에 실패했습니다. 루트 디렉토리에 있는 업데이트 패키지를 수동으로 압축 해제해 보십시오.</system:String>
<system:String x:Key="ErrorSolutionReplaceAdb">에뮬레이터와 ADB를 종료하거나 컴퓨터를 재시작하고 관리자 권한으로 MAA를 실행해 주세요.</system:String>
<system:String x:Key="ErrorSolutionFailedToMove">파일이 사용 중입니다. 컴퓨터를 다시 시작하고 다시 시도하세요.</system:String>
<system:String x:Key="ErrorSolutionSelectDefaultBrowser">링크 열기 실패. "Windows 설정"으로 이동하여 기본 브라우저를 선택하세요.</system:String>

View File

@@ -51,7 +51,7 @@
<system:String x:Key="UseGpuForInference">使用 GPU 加速推理</system:String>
<system:String x:Key="GpuOptionDisable">不使用</system:String>
<system:String x:Key="GpuOptionSystemDefault">系统默认 GPU</system:String>
<!-- 设置指引 -->
<system:String x:Key="TaskSettings">任务设置</system:String>
<system:String x:Key="SettingsGuide">设置指引</system:String>
@@ -596,6 +596,7 @@
<system:String x:Key="ErrorDetails">详细信息</system:String>
<system:String x:Key="ErrorSolution">解决方案</system:String>
<system:String x:Key="ErrorSolutionCrash">请参考文档: 常见问题 - 闪退 进行操作。</system:String>
<system:String x:Key="ErrorSolutionUpdatePackageExtractionFailed">解压更新包失败,请尝试手动解压根目录下更新包。</system:String>
<system:String x:Key="ErrorSolutionReplaceAdb">请「关闭模拟器与 ADB」或「重启电脑后在未开启模拟器的情况下使用管理员权限打开 MAA」后进行操作。</system:String>
<system:String x:Key="ErrorSolutionFailedToMove">文件被占用,请重启电脑后重试。</system:String>
<system:String x:Key="ErrorSolutionSelectDefaultBrowser">打开链接失败请前往「Windows 设置」选择默认浏览器。</system:String>

View File

@@ -587,6 +587,7 @@
<system:String x:Key="ErrorDetails">詳細資訊</system:String>
<system:String x:Key="ErrorSolution">解決方法</system:String>
<system:String x:Key="ErrorSolutionCrash">請參考文件: 常見問題 - 閃退 進行操作。</system:String>
<system:String x:Key="ErrorSolutionUpdatePackageExtractionFailed">解壓更新包失敗,請嘗試手動解壓根目錄下更新包。</system:String>
<system:String x:Key="ErrorSolutionReplaceAdb">請關閉模擬器與 ADB 或重開電腦後,使用系統管理員身分執行 MAA 進行操作。</system:String>
<system:String x:Key="ErrorSolutionFailedToMove">檔被佔用,請重開電腦後重試。</system:String>
<system:String x:Key="ErrorSolutionSelectDefaultBrowser">打開連結失敗請前往「Windows 設置」選擇默認瀏覽器。</system:String>

View File

@@ -256,7 +256,15 @@ namespace MaaWpfGui.ViewModels.UI
}
}
File.Move(path, moveTo);
try
{
File.Move(path, moveTo);
}
catch (Exception e)
{
_logger.Error($"move file error, path: {path}, moveTo: {moveTo}, error: {e.Message}");
throw;
}
}
}
@@ -279,18 +287,26 @@ namespace MaaWpfGui.ViewModels.UI
}
string curFileName = file.Replace(extractDir, curDir);
if (File.Exists(curFileName))
try
{
string moveTo = file.Replace(extractDir, oldFileDir);
if (File.Exists(moveTo))
if (File.Exists(curFileName))
{
DeleteFileWithBackup(moveTo);
string moveTo = file.Replace(extractDir, oldFileDir);
if (File.Exists(moveTo))
{
DeleteFileWithBackup(moveTo);
}
File.Move(curFileName, moveTo);
}
File.Move(curFileName, moveTo);
File.Move(file, curFileName);
}
catch (Exception e)
{
_logger.Error($"move file error, file name: {file}");
throw;
}
File.Move(file, curFileName);
}
// 操作完了,把解压的文件删了
@@ -308,8 +324,9 @@ namespace MaaWpfGui.ViewModels.UI
{
File.Delete(filePath);
}
catch (Exception)
catch (Exception e)
{
_logger.Error($"delete file error, filePath: {filePath}, error: {e.Message}, try to backup.");
int index = 0;
string currentDate = DateTime.Now.ToString("yyyyMMddHHmm");
string backupFilePath = $"{filePath}.{currentDate}.{index}";
@@ -320,7 +337,15 @@ namespace MaaWpfGui.ViewModels.UI
backupFilePath = $"{filePath}.{currentDate}.{index}";
}
File.Move(filePath, backupFilePath);
try
{
File.Move(filePath, backupFilePath);
}
catch (Exception e1)
{
_logger.Error($"move file error, path: {filePath}, moveTo: {backupFilePath}, error: {e1.Message}");
throw;
}
}
}
}

View File

@@ -89,6 +89,11 @@ namespace MaaWpfGui.Views.UI
return LocalizationHelper.GetString("ErrorSolutionCrash");
}
if (details.Contains("CheckAndUpdateNow()") && details.Contains("MoveFile"))
{
return LocalizationHelper.GetString("ErrorSolutionUpdatePackageExtractionFailed");
}
if (details.Contains("Hyperlink_Click") && details.Contains("StartWithShellExecuteEx"))
{
return LocalizationHelper.GetString("ErrorSolutionSelectDefaultBrowser");