Files
photocraft/crates/format
Michael Higgins 1253e79d68 fix(format): treat an unsupported directory flush on Windows as done (#9440)
Fixes #9440
Fixes #9787
Fixes #9535

## Cause
Saving to a mapped SMB drive on Windows publishes the file, then `AtomicFs::sync_dir` fails with `ERROR_INVALID_FUNCTION` (os error 1): the share cannot flush a directory handle. Since #8034 (for #7858) every Windows flush failure fails the save, so the document stays dirty and the save looks failed even though the file is in place. Unix already treats "directory flush unsupported" as done (`dir_synced`, #5420); Windows had no equivalent.

## Fix
`dir_synced`/`dir_sync_unsupported` now exist on all platforms and, on Windows, count `ERROR_INVALID_FUNCTION` (1), `ERROR_NOT_SUPPORTED` (50) and `ErrorKind::Unsupported` as "cannot flush directories". `atomic_write` and the bundle store use it before `publication_error`. `ERROR_ACCESS_DENIED`, I/O errors and everything else still fail the save, so the #7858 protection stays for real failures.

## Tested locally
`cargo fmt --all`; `cargo clippy -p photocraft-format --lib --tests -- -D warnings`; `cargo test -p photocraft-format --lib atomic` (includes new `windows_unsupported_directory_flush_codes_are_classified`). Not replayed on a real SMB share. The full gate was left to CI.


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
  * On Windows, saves now succeed when directory flushing reports that the operation is unsupported, including during bundle publication and directory saves. This applies to unsupported-operation errors such as `ERROR_INVALID_FUNCTION` and `ERROR_NOT_SUPPORTED`. Other directory-flush errors, including access denied, continue to cause the save to fail and be reported.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-11 07:31:44 +01:00
..