{"record":{"id":"7018c973a1c9ef23","repo":"OdysseusYuan/LKY_OfficeTools","slug":"a","errorCode":null,"errorMessage":"下载 {a} 异常！","messagePattern":"下载 (.+?) 异常！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"LKY_OfficeTools/Lib/Lib_OfficeDownload.cs","lineNumber":51,"sourceCode":"                Thread.Sleep(1000);\n\n                //轮询下载所有文件\n                foreach (var a in OfficeNetInfo.OfficeFileList)\n                {\n                    //根据官方目录，来调整下载保存位置\n                    string save_path = save_to + a.Substring(OfficeNetInfo.OfficeUrlRoot.Length).Replace(\"/\", \"\\\\\");\n\n                    //保存到List里面，用于后续检查\n                    save_files.Add(save_path);\n\n                    new Log($\"\\n     >> 下载 {new FileInfo(save_path).Name} 文件中，请稍候 ...\", ConsoleColor.DarkYellow);\n\n                    //遇到重复的文件可以断点续传\n                    int down_result = Lib_Aria2c.DownFile(a, save_path);\n                    if (down_result != 1)\n                    {\n                        //如果因为核心下载exe丢失，导致下载失败，直接中止\n                        throw new Exception($\"下载 {a} 异常！\");\n                    }\n\n                    //如果用户中断了下载，则直接跳出\n                    if (Lib_AppState.Current_StageType == Lib_AppState.ProcessStage.Interrupt)\n                    {\n                        return -1;\n                    }\n\n                    new Log($\"     √ 已下载 {new FileInfo(save_path).Name} 文件。\", ConsoleColor.DarkGreen);\n                }\n\n                new Log($\"\\n------> 正在检查 Office v{OfficeNetInfo.OfficeLatestVersion} 文件 ...\", ConsoleColor.DarkCyan);\n\n                foreach (var b in save_files)\n                {\n                    string aria_tmp_file = b + \".aria2c\";\n\n                    //下载完成的标志：文件存在，且不存在临时文件","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/OdysseusYuan/LKY_OfficeTools/blob/6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf/LKY_OfficeTools/Lib/Lib_OfficeDownload.cs#L33-L69","documentation":"Thrown when Lib_Aria2c.DownFile returns a value other than 1. DownFile returns 1 on success, 0 when the aria2c binary (lot_aria2c.exe) is missing from the SDK path, and -1 when Com_ExeOS.Run.Exe fails to launch the process (sentinel -920921) or any other exception occurs. The source comment confirms this is designed to abort when the core download engine is lost. Note: genuine download failures where aria2c exits non-zero but the process launched are NOT caught — DownFile still returns 1 because it only checks the launcher sentinel, not aria2c's own exit code.","triggerScenarios":"DownFile returns 0 when Documents\\SDKs\\Aria2c\\lot_aria2c.exe does not exist on disk, or -1 when Run.Exe cannot start the aria2c process (returns -920921) or throws. Both make the caller's `down_result != 1` branch throw.","commonSituations":"The SDK bundle was not extracted; antivirus quarantined lot_aria2c.exe; the SDKs_Root path points to a wrong location; a partial/corrupted install left the binary absent; permissions prevent executing the exe.","solutions":["Verify lot_aria2c.exe exists at Documents.SDKs.SDKs_Root + @\"\\Aria2c\\lot_aria2c.exe\" and is executable.","Re-extract or re-download the SDK bundle to restore the missing binary.","Add the SDK directory to antivirus exclusions if the binary keeps disappearing.","Confirm SDKs_Root resolves to the correct absolute path for the current install.","If down_result is -1 (launcher exception), inspect the Log output for the Run.Exe failure cause."],"exampleFix":"// before\nint down_result = Lib_Aria2c.DownFile(a, save_path);\nif (down_result != 1)\n{\n    throw new Exception($\"下载 {a} 异常！\");\n}\n\n// after — distinguish the two failure codes for actionable messages\nint down_result = Lib_Aria2c.DownFile(a, save_path);\nif (down_result == 0)\n{\n    throw new Exception($\"下载引擎 aria2c 丢失，请重新提取 SDK 后重试。\");\n}\nif (down_result == -1)\n{\n    throw new Exception($\"下载 {a} 失败：引擎无法启动，请查看日志。\");\n}","handlingStrategy":"validation","validationCode":"// Verify the aria2c binary exists before entering the download loop.\nstring aria2c_path = Documents.SDKs.SDKs_Root + @\"\\Aria2c\\lot_aria2c.exe\";\nif (!File.Exists(aria2c_path))\n{\n    new Log($\"下载引擎丢失：{aria2c_path}，请重新提取 SDK。\", ConsoleColor.DarkRed);\n    // trigger SDK re-extraction or abort the batch before any DownFile call\n    return;\n}","typeGuard":null,"tryCatchPattern":"// Wrap the per-file download so one failure gives an actionable message without masking the cause.\ntry\n{\n    int down_result = Lib_Aria2c.DownFile(a, save_path);\n    if (down_result == 0) throw new Exception($\"aria2c 引擎丢失：{aria2c_path}\");\n    if (down_result == -1) throw new Exception($\"引擎启动失败，下载 {a}\");\n}\ncatch (Exception ex)\n{\n    new Log($\"下载 {a} 失败：{ex.Message}\", ConsoleColor.DarkRed);\n    // decide: retry, skip, or abort the whole batch\n}","preventionTips":["Bundle the aria2c binary with the installer and verify its presence on startup.","Add the SDK directory to antivirus exclusions so lot_aria2c.exe is not quarantined.","Pin and validate SDKs_Root at launch; fail fast with a clear message if the path is wrong.","Treat DownFile result 0 and -1 as distinct cases in logging."],"tags":["download","aria2c","missing-binary","sdk","external-process"],"backgroundTag":null,"analyzedSha":"6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf","analyzedAt":"2026-08-13T18:00:34.810Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}