Repository navigation
Watch folders: wait for a file's data, and retry a file that failed - #1127
Merged
Merged
Conversation
A file that opens without sharing and keeps its size and time for 2 seconds can still hold nothing: a program can reserve the size, let go, and write later. ImageMagick then says "improper image header" for a file that is fine a moment later. A watch folder now waits for data at the start of the file (up to 30 seconds, as some formats do start with zeros and a damaged file must get its error). A file that failed was never looked at again before it changed, because it counted as handled before its conversion ran; a batch that could not start at all was forgotten without a word. Both now get one more turn after 10 seconds. Refs #767 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test rewrote a file with the same size right after writing it and expected the settle wait to start over. Within the file system's clock tick the time stays the same, so nothing shows that the file changed: on CI it converted at once. That was the file with its data in it, so the watcher did nothing wrong. A real writer comes later, so the test now gives the rewrite a later time. Refs #767 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
1 task done
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.
Refs #767 (the reporter still owes a log, so this doesn't close it)
What I measured
improper image header ... ReadPNGImagecomes from ImageMagick. It means the first bytes of the file aren't a signature ImageMagick knows. With the real engine:.pngholdingimproper image headerimproper image headerunexpected end-of-file(another message)A burst alone doesn't cause it. Real
filee watch, files dropped with the Shell'sMoveHere/CopyHere(the engine Explorer uses):originals. Copied: the same.InternalBufferSizeand theErrorrescan lose nothing here, so "only 70" isn't a missed event as far as I can reproduce.This doesn't reproduce the report. It closes what is really wrong in that path.
What was wrong
main:failed: improper image header, thendone. Now it waits for data at its start, for up to 30 s: some formats do start with zeros (ISO), and a damaged file must still get its error. It reads 4 KB, so DICOM's 128-byte preamble doesn't wait._handledis filled before the conversion runs. It now gets one more turn after 10 s, per version of the file, so a broken file reports twice and then stays quiet. The cost: a broken file makes a second failed job in the toast, and a long video that fails at the end runs twice._convertreturned null or threw). It gets the same one retry.The change to
FolderWatcheris small and additive, as a private branch edits other parts of that file.Not changed
An overflow rescan in Keep mode also notices files that were already there and converts them again. Rare (it takes thousands of events), and unrelated to this report.
Tests
FolderWatcherTests: 7 new cases fail againstmain'sFolderWatcher.cs.FolderWatcherTests,WatchRuleOptionsTests,WatchResultsTests,FolderCopyTests: 87 passed, 2 skipped. CLI watch tests: 8 passed.dotnet format --verify-no-changesclean on the changed files.🤖 Generated with Claude Code