{"record":{"id":"a7f979ce684730a6","repo":"beeradmoore/dlss-swapper","slug":"downloadfiletostreamasync-returned-false","errorCode":null,"errorMessage":"DownloadFileToStreamAsync returned false.","messagePattern":"DownloadFileToStreamAsync returned false\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Data/GitHub/GitHubUpdater.cs","lineNumber":365,"sourceCode":"            var fileDownloader = new FileDownloader(gitHubAsset.BrowserDownloadUrl);\n\n            try\n            {\n                using (var fileStream = File.Create(tempDownloadFile))\n                {\n                    var downloaderTask = fileDownloader.DownloadFileToStreamAsync(fileStream, cancellationTokenSource.Token, progressCallback: (downloadedBytes, totalBytes, percent) =>\n                    {\n                        var displayPercent = percent * 100;\n                        progressRun.Text = $\"{ByteSize.FromBytes(downloadedBytes).MegaBytes.ToString(\"F2\", CultureInfo.CurrentCulture)} / {totalSizeString} ({percent:F1}%)\";\n                        filesProgressBar.IsIndeterminate = false;\n                        filesProgressBar.Value = percent;\n                    });\n\n\n                    var didDownload = await downloaderTask;\n                    if (didDownload == false)\n                    {\n                        throw new Exception(\"DownloadFileToStreamAsync returned false.\");\n                    }\n\n                    downloadingDialog.Hide();\n                }\n\n            }\n            catch (TaskCanceledException) when (cancellationTokenSource.IsCancellationRequested)\n            {\n                // User cancelled.\n                downloadingDialog.Hide();\n                return;\n            }\n            catch (Exception ex)\n            {\n                Logger.Error(ex);\n                downloadingDialog.Hide();\n\n                var downloadErrorDialog = new EasyContentDialog(xamlRoot)","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/beeradmoore/dlss-swapper/blob/ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb/src/Data/GitHub/GitHubUpdater.cs#L347-L383","documentation":"During DownloadAndInstallAsync the updater starts a task that downloads the new installer file into a stream (DownloadFileToStreamAsync). That helper reports success/failure as a bool; when it returns false the download did not complete, so the update cannot proceed and the code throws.","triggerScenarios":"DownloadFileToStreamAsync returns false: network interruption mid-download, GitHub returning a non-success status, the download stream failing to write, or the HTTP response being empty.","commonSituations":"Unstable Wi-Fi or VPN dropping mid-download, corporate proxy blocking the GitHub release download URL, insufficient disk space on the temp drive, or GitHub CDN (objects.githubusercontent.com) errors.","solutions":["Retry the download; transient network failures are the most common cause. Add automatic retry with backoff around the download task.","Check network connectivity and any proxy/firewall blocking github.com/objects.githubusercontent.com.","Verify free disk space in the temp download location.","Download the installer manually from the GitHub releases page and install it if automatic download keeps failing."],"exampleFix":"// before\nvar didDownload = await downloaderTask;\nif (didDownload == false)\n    throw new Exception(\"DownloadFileToStreamAsync returned false.\");\n// after\nvar didDownload = await downloaderTask;\nif (didDownload == false)\n{\n    downloadingDialog.Hide();\n    throw new Exception(\"Update download failed. Check your network connection and try again.\");\n}","handlingStrategy":"retry","validationCode":"// Pre-check network and disk space before starting the download\nif (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == false)\n    return; // don't attempt download\nvar drive = new DriveInfo(Path.GetTempPath());\nif (drive.AvailableFreeSpace < requiredInstallerSize)\n    return; // not enough space","typeGuard":null,"tryCatchPattern":"try\n{\n    await updater.DownloadAndInstallAsync();\n}\ncatch (Exception ex) when (ex.Message.Contains(\"DownloadFileToStreamAsync\"))\n{\n    logger.LogWarning(ex, \"Update download failed; prompt user to retry\");\n    // show retry dialog instead of crashing\n}","preventionTips":["Wrap the download in a retry loop with exponential backoff for transient failures","Check network availability and free disk space before downloading","Clean up partially downloaded temp files so a retry starts fresh","Offer a manual download link when automatic download fails"],"tags":["download","network","update","github"],"backgroundTag":"network-request-failed","analyzedSha":"ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb","analyzedAt":"2026-09-15T05:25:32.979Z","contentChangedAt":"2026-09-15T05:25:32.979Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}