Skip to content

Comments

platform: use FILE_FLAG_WRITE_THROUGH on Windows for SyncFile data durability, fixes #9388#9389

Open
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:win32-syncfile-write-through
Open

platform: use FILE_FLAG_WRITE_THROUGH on Windows for SyncFile data durability, fixes #9388#9389
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:win32-syncfile-write-through

Conversation

@mr-raj12
Copy link
Contributor

Description

Implement Windows-native SyncFile using CreateFileW with FILE_FLAG_WRITE_THROUGH to bypass volatile write caches and write directly to persistent storage. This is the Windows equivalent of the macOS F_FULLFSYNC fix (#9383 / PR #9385).

Fixes #9388

Changes

  • src/borg/platform/windows.pyx — add SyncFile subclass using CreateFileW + FILE_FLAG_WRITE_THROUGH; falls back to base when an existing fd is provided (e.g. SaveFile)
  • src/borg/platform/__init__.py — import SyncFile from .windows instead of .base
  • src/borg/platform/base.py — update resolved TODO comment
  • src/borg/testsuite/platform/platform_test.py — add skipif_not_win32 marker
  • src/borg/testsuite/platform/windows_test.py — 6 tests (write/read, FileExistsError, text mode, fd fallback, sync, write-through flag verification)

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.43%. Comparing base (0354697) to head (59dcf0e).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/platform/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9389   +/-   ##
=======================================
  Coverage   76.43%   76.43%           
=======================================
  Files          85       85           
  Lines       14800    14800           
  Branches     2212     2212           
=======================================
  Hits        11313    11313           
  Misses       2809     2809           
  Partials      678      678           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

platform: implement Windows-native SyncFile using FILE_FLAG_WRITE_THROUGH

1 participant