OpenImageIO
OpenImageIO copied to clipboard
[BUG] ImageCache doesn't invalidate if no change in modification time
Describe the bug
I loaded two images from the same path. The file was changed between the two operations but since the file's modification time stayed the same (in seconds) ImageCache didn't invalidate it:
If the change takes a longer time such that the modification time of the file, which has seconds resolution, differs for the second image load, buf2 will load from the correct, updated file and that would be the expected behaviour always.
To Reproduce Steps to reproduce the behavior:
std::string filePath = ...;
// Save an image to filePath
ImageBuf buf1(filePath);
// Save another image to filePath
ImageBuf buf2(filePath);
Expected behavior
I expect buf2 to hold the update image which is the case if the modification time is updated (in seconds) for the second operation.
Evidence
This is intentional behavior of the ImageCache as we can see it here: https://github.com/OpenImageIO/oiio/blob/003a1f15aeb4a7ee7e31c0c21c27eafc9b981f57/src/libtexture/imagecache.cpp#L3395
I don't think ignoring the changes of a file should depend on the resolution of the file time, at least not if the resolution is seconds.
Platform information:
- OIIO branch/version: 2.3.7.2
- OS: macOS 12.6.2 (21G320)
- C++ compiler: Apple clang version 14.0.0 (clang-1400.0.29.202)
- Any non-default build flags when you build OIIO: none