Update modified time when closing written files#86
Conversation
|
Follow-up verification:
I still do not have CMake/Ruby/a C toolchain available on this Windows host to run the new unit test locally. |
Add opt-in ffconfigUPDATE_FILE_MODIFIED_TIME_ON_CLOSE and track writes/truncation so FF_Close can refresh xModifiedTime when closing a modified file. Cover the close-time update path with unit tests. Use a narrow ff_dir mock subset so CMock does not generate both ASCII and UTF-16 directory prototypes from ff_dir.h. Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
3a2287f to
dcb722d
Compare
rawalexe
left a comment
There was a problem hiding this comment.
Verified the xUpdateDirectoryEntry gating: it's correctly OR'd — set independently in the size-changed block and the modified-flag block, both writing into the same xOriginalEntry before a single consolidated FF_PutEntry. No clobbering between the two triggers. Nice disk-I/O consolidation.
One open question: is FF_VALID_FLAG_MODIFIED guaranteed to be cleared/reset before a file handle is reused from the pool, in case FF_PutEntry fails here? Not blocking since the handle appears to be freed/reset elsewhere in FF_Close, but worth a quick confirmation or a test case for the failed-write path.
Feature is opt-in (ffconfigUPDATE_FILE_MODIFIED_TIME_ON_CLOSE default 0) so zero-cost by default. LGTM.
cd78491 to
3d51b80
Compare
CMock does not evaluate the ffconfigHASH_CACHE condition when it parses ff_ioman.h, so the generated mock referenced FF_HashTable_t even though the unit-test config leaves the hash cache disabled. Use a narrow ff_ioman mock subset for the ff_file close tests, matching the existing ff_dir subset pattern and keeping the mock surface to FF_FlushCache(). Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
A later block failure can leave earlier chunks written while FF_Write returns an error. Track the successful final partial count and set modified whenever any bytes were written so close-time timestamps reflect the content change. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
FF_WriteClusters can complete a block write before a later FAT traversal fails. Report completed clusters to FF_Write so close-time timestamp tracking still records the content change. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
Closes #81 ## Summary - Add
ffconfigUPDATE_FILE_MODIFIED_TIME_ON_CLOSE, defaulting to0to preserve existing close-time behavior. - Track actual file changes withFF_VALID_FLAG_MODIFIEDafter successful writes or EOF truncation, including partial writes and completed cluster writes followed by a later error. - Reuse the existingFF_Close()directory-entry update to refreshxModifiedTimewhen the opt-in config is enabled. - Keep theff_filemetadata tests on narrow mock subsets instead of generating the fullff_ioman.hmock surface. ## Testing -git diff --check-cmake -S . -B _build/project -G Ninja -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF -DFREERTOS_PLUS_FAT_PORT=POSIX-cmake --build _build/project --target freertos_plus_fat_build_test --parallel- The fourff_fileCMock tests pass in a local MinGW harness, including later block-write failure and successful cluster write followed by FAT traversal failure. - Uncrustify 0.69.0--checkpasses forff_file.candtest/unit-test/ff_file_utest.c. - The native MinGW CMake unit-test target cannot link CMock's shared mock library because its strict-order globals are defined by the test runner. The local harness links the same generated mocks and runner into one executable; the official unit-test job runs on Ubuntu. ## CI notes7048dcaaddsFF_DecreaseFreeClustersto the narrowff_iomanmock subset, resolving theff_file_utestlink error from the previous run.7048dcaab964a73acafe367a07a4c2cc5780c68fisaction_requiredwith no jobs. It is awaiting maintainer workflow approval before the unit-test matrix can run.