Skip to content

DirectDownload ignores close-time write failures

Summary

DirectDownload::DownloadUrlToFile checks each _write, but it ignores the final _close result. Some filesystems and volumes can report delayed write, flush, or quota failures only at close time. The current code can therefore report a downloaded update artifact as successful even when final persistence failed.

This blocks Beta 0.7.3 for release update inputs because failed or partial downloaded artifacts must not be promoted as valid.

Evidence

  • srchybrid/DirectDownload.cpp:111 opens the target with CRT write-only file APIs.
  • srchybrid/DirectDownload.cpp:128 checks short or failed _write calls.
  • srchybrid/DirectDownload.cpp:136 calls _close(fdOut) and ignores the return value.
  • srchybrid/DirectDownload.cpp:138 deletes the target only when earlier loop logic set bSuccess false.

Execution Plan

  1. Revalidate all callers of DownloadUrlToFile, especially GeoLocation and IPFilter update flows.
  2. Treat _close failure as a download failure and preserve the existing temporary-file cleanup behavior.
  3. Capture the correct close-time errno before any cleanup can overwrite it.
  4. Ensure an empty or failed artifact is not promoted by callers.
  5. Add focused seam coverage for successful write plus failed close.
  6. Re-run GeoLocation/IPFilter update-related tests and the smallest relevant app validation.

Acceptance Criteria

  • Close-time persistence failure returns false from DownloadUrlToFile.
  • Failed artifacts are deleted like earlier read/write failures.
  • Error text preserves enough detail to diagnose full disk, quota, or volume failure.
  • Existing successful download behavior is unchanged.

Validation

  • 2026-05-08: Done in app commit c237d48.
  • python -m emule_workspace build app --workspace-root . --config Release --platform x64 --variant main passed; log root workspaces\v0.72a\state\build-logs\20260508-095637.
  • python -m emule_workspace build tests --workspace-root . --config Release --platform x64 --test-run-variant main passed; log root workspaces\v0.72a\state\build-logs\20260508-095657.
  • python -m emule_workspace validate --workspace-root . passed.
  • Focused doctest passed: repos\emulebb-build-tests\build\eMulebb-workspace-v0.72a-eMule-main\x64\Release\emule-tests.exe --test-suite=parity --test-case="IP-filter update seam rejects markup download payloads".
  • Code validation: DirectDownload::DownloadUrlToFile now treats _close failure as a failed download and deletes the target like earlier read/write failures.