netchx/netch · warning · MessageException

Download Update File Failed: {e1.Message}

Error message

Download Update File Failed: {e1.Message}

What it means

Thrown by MainForm's update routine when WebUtil.DownloadFileAsync(updateFileUrl, updateFileFullName, progress) raised any exception while fetching the new release asset. The exception is logged as a Warning and rethrown as a MessageException carrying the inner message. The update is aborted (caught upstream and shown as a tip).

Source

Thrown at Netch/Forms/MainForm.cs:468

            if (File.Exists(updateFileFullName))
            {
                var fileHash = await Utils.Utils.Sha256CheckSumAsync(updateFileFullName);
                if (fileHash == sha256)
                    downloaded = true;
                else
                    File.Delete(updateFileFullName);
            }

            if (!downloaded)
            {
                try
                {
                    await WebUtil.DownloadFileAsync(updateFileUrl, updateFileFullName, progress);
                }
                catch (Exception e1)
                {
                    Log.Warning(e1, "Download Update File Failed");
                    throw new MessageException($"Download Update File Failed: {e1.Message}");
                }

                var fileHash = await Utils.Utils.Sha256CheckSumAsync(updateFileFullName);
                if (fileHash != sha256)
                    throw new MessageException(i18N.Translate("The downloaded file has the wrong hash"));
            }

            await StopAsync();
            await Configuration.SaveAsync();

            // Update
            await Task.Run(updater.ApplyUpdate);

            // release mutex, exit
            Program.SingleInstance.Dispose();
            Process.Start(Global.NetchExecutable);
            Environment.Exit(0);
        }

View on GitHub (pinned to 9d99eb1c5a)

Solutions

  1. Retry the update check/download later (the routine re-validates the hash of any partial file first).
  2. Check network/proxy connectivity to the release asset URL shown in UpdateChecker.LatestRelease.
  3. Ensure the data\ download directory is writable and has free space.
  4. If a proxy is required, configure the system proxy so WebUtil can reach the asset.
  5. Manually download the asset and place it under data\<updateFileName> so the hash check short-circuits the download.
Defensive patterns

Strategy: retry

Validate before calling

// Best-effort pre-check: ensure the target directory is writable and has space.
Directory.CreateDirectory(Path.GetDirectoryName(updateFileFullName)!);
if (new DriveInfo(Path.GetPathRoot(updateFileFullName)!).AvailableFreeSpace < 50L * 1024 * 1024)
    throw new MessageException("Not enough free space for the update download.");

Try / catch

for (int attempt = 0; attempt < 3; attempt++)
{
    try { await WebUtil.DownloadFileAsync(updateFileUrl, updateFileFullName, progress); break; }
    catch (Exception e1) when (attempt < 2)
    {
        Log.Warning(e1, "Download attempt {N} failed, retrying", attempt + 1);
        File.Delete(updateFileFullName); // the hash check below would reject a partial file anyway
    }
}

Prevention

When it happens

Trigger: Network interruption or timeout during download; update server returned 5xx or a broken URL; proxy/firewall blocking the GitHub release asset; disk full at the download path; the pre-existing file was deleted and a transient error occurred re-fetching.

Common situations: Unstable connection mid-download; corporate proxy blocking github release downloads; the selected release asset URL changed; transient server-side error.

Related errors


AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13). Data as JSON: /api/errors/e216dd7c477e4c7e. Report an issue: GitHub.