Repository navigation
fix(locallibrary): wait for a new Windows volume before writing FAT32 - #496
Merged
Merged
Conversation
Format-Volume returns, and the partition gets its letter, a moment before Windows can open the volume, so write_fat32's open failed with ERROR_NOT_READY. It now retries that error for up to 10 seconds, as the volume lock after it already does. The disk-image test harness asked Get-DiskImage about an image whose folder was gone, which fails even with SilentlyContinue. A file that's gone isn't attached, since Windows holds an attached image's file open. Fixes LOC-255
bnb
previously approved these changes
Nov 7, 2026
Rust coverageFrom run 620. Both are held to the thresholds in .cargo/config.toml.
|
… a real disk image
bnb
previously approved these changes
Nov 9, 2026
…g a dismounted volume write_fat32 flushed the volume after dismounting it. Once a volume is dismounted, the file system answers anything but reads and writes on that handle with STATUS_VOLUME_DISMOUNTED, which Windows reports as ERROR_NOT_READY: "The device is not ready". The open was never the problem, so the wait before it goes, with its test. Writes to a volume handle skip the cache already, so the volume is now opened with FILE_FLAG_WRITE_THROUGH, which takes over the flush's other job of getting each write past the drive's own cache.
bnb
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes LOC-255.
Both Windows disk-image tests failed in the weekly run of 11-02, for two separate reasons.
formats_the_image_it_attached_as_plannedfailed informat::applywithIo { path: "\\.\E:", source: Os { code: 21, message: "The device is not ready." } }.write_fat32dismounts the volume, writes FAT32 over it, then callssync_all(FlushFileBuffers) on the same handle. AfterFSCTL_DISMOUNT_VOLUMEthe file system lets that handle read and write, but answers other requests withSTATUS_VOLUME_DISMOUNTED(see the FAT driver's dismount handler and write path). Win32 reports that status asERROR_NOT_READY(Wine's table). A real USB drive gets the same error, so this is a fix toformat, not only to the test.an_image_is_detached_when_its_test_endspanicked in the harness'sos::attachedafter the guard dropped the image. The guard deletes the image's temp folder, andGet-DiskImage -ImagePathfor a file that doesn't exist fails with exit 1 and no output, even with-ErrorAction SilentlyContinue.Changed
format/windows.rs:write_fat32opens the volume withFILE_FLAG_WRITE_THROUGHand no longer flushes it. Writes to a volume handle skip the cache already (write.c), and write-through gets each one past the drive's own cache before it returns.format/tests/disk_image.rs: on Windows,os::attachedanswersNonefor an image file that's gone, without running PowerShell. Windows keeps an attached image's file open, so a file that's gone can't be attached.apps/locallibrary/changes/.How it was tested
cargo nextest run -p locallibrary --lib -E 'test(/^format::/)': 127 passed on macOS.cargo clippy -p locallibrary --all-targets -- -D warnings, for the host and forx86_64-pc-windows-gnu, andcargo fmt --check.