{"record":{"id":"2103a76f78a0bc57","repo":"netchx/netch","slug":"update-file-main-program-not-exist","errorCode":null,"errorMessage":"Update file main program not exist","messagePattern":"Update file main program not exist","errorType":"exception","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"Netch/Services/Updater.cs","lineNumber":47,"sourceCode":"    #region Apply Update\n\n    internal void ApplyUpdate()\n    {\n        var extractPath = Path.Combine(_tempDirectory, \"extract\");\n\n        int exitCode;\n        if ((exitCode = Extract(extractPath)) != 0)\n            throw new MessageException(i18N.Translate($\"7za unexpectedly exited. ({exitCode})\"));\n\n        // update archive file must have a top-level directory \"Netch\"\n        var updateDirectory = Path.Combine(extractPath, \"Netch\");\n        if (!Directory.Exists(updateDirectory))\n            throw new MessageException(i18N.Translate(\"Update file top-level directory not exist\"));\n\n        // {_tempDirectory}/extract/Netch/Netch.exe\n        var updateMainProgramFilePath = Path.Combine(updateDirectory, \"Netch.exe\");\n        if (!File.Exists(updateMainProgramFilePath))\n            throw new MessageException(i18N.Translate($\"Update file main program not exist\"));\n\n        MarkFilesOld();\n\n        // move {tempDirectory}\\extract\\Netch to install folder\n        MoveFilesOver(updateDirectory, InstallDirectory);\n    }\n\n    private void MarkFilesOld()\n    {\n        var keepDirFullPath = KeepDirectories.Select(d => Path.Combine(InstallDirectory, d)).ToImmutableList();\n\n        foreach (var file in Directory.GetFiles(InstallDirectory, \"*\", SearchOption.AllDirectories))\n        {\n            if (keepDirFullPath.Any(p => file.StartsWith(p)))\n                continue;\n\n            if (KeepFiles.Contains(Path.GetFileName(file)))\n                continue;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/netchx/netch/blob/9d99eb1c5a2acbf2a34f2600f94242601019a300/Netch/Services/Updater.cs#L29-L65","documentation":"After confirming the top-level 'Netch' directory exists, the updater requires Netch.exe inside it (Path.Combine(updateDirectory, \"Netch.exe\")). A missing executable means the package is incomplete (truncated or a wrong/partial variant), and the update is aborted before MarkFilesOld/MoveFilesOver run, to avoid leaving the install broken.","triggerScenarios":"Archive contains the 'Netch' folder but not Netch.exe: a partial/truncated archive, a debug-only build package, a delta/patch variant, or antivirus removing Netch.exe from the extracted folder.","commonSituations":"Truncated download that 7za still partially extracted; a release package variant that omits the main exe; AV quarantine of Netch.exe after extraction.","solutions":["Re-download the complete package and verify its SHA256.","Confirm the package is the full release, not a delta/patch variant.","Whitelist the Netch folder in antivirus so Netch.exe is not removed post-extract.","Inspect the extracted 'Netch' folder to see which critical files are missing."],"exampleFix":"// before\nvar updateMainProgramFilePath = Path.Combine(updateDirectory, \"Netch.exe\");\nif (!File.Exists(updateMainProgramFilePath))\n    throw new MessageException(i18N.Translate($\"Update file main program not exist\"));\n// after - validate all critical files and report which are missing\nvar required = new[] { \"Netch.exe\" };\nvar missing = required.Where(f => !File.Exists(Path.Combine(updateDirectory, f))).ToList();\nif (missing.Any())\n    throw new MessageException($\"Update package missing: {string.Join(\", \", missing)}\");","handlingStrategy":"validation","validationCode":"var exe = Path.Combine(updateDirectory, \"Netch.exe\");\nif (!File.Exists(exe) || new FileInfo(exe).Length == 0)\n    throw new MessageException(\"Update package is missing a valid Netch.exe\");","typeGuard":null,"tryCatchPattern":"try { updater.ApplyUpdate(); }\ncatch (MessageException ex) when (ex.Message.Contains(\"main program not exist\"))\n{\n    Log.Error(\"Update package incomplete: {Msg}\", ex.Message);\n    Global.MainForm.NotifyTip(\"Update incomplete (no Netch.exe). Re-download the full release.\");\n}","preventionTips":["Hash-verify the full archive so truncation is caught before extraction.","Have the release script assert Netch.exe is present in the staged 'Netch' folder.","Keep MarkFilesOld strictly after all critical files are confirmed present."],"tags":["updater","archive","install","packaging"],"backgroundTag":null,"analyzedSha":"9d99eb1c5a2acbf2a34f2600f94242601019a300","analyzedAt":"2026-08-13T14:12:19.105Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}