Open xsdg opened 6 days ago
Okay, so I replaced rm -rf
with rm -rfv
to show how rm
progresses through the directory tree. That shows the following:
removed directory '/tmp/tmp.4lL6wQPEf9/.runtime/dbus-1/services'
removed directory '/tmp/tmp.4lL6wQPEf9/.runtime/dbus-1'
rm: cannot remove '/tmp/tmp.4lL6wQPEf9/.runtime/doc': Is a directory
removed '/tmp/tmp.4lL6wQPEf9/.runtime/dconf/user'
removed directory '/tmp/tmp.4lL6wQPEf9/.runtime/dconf'
removed directory '/tmp/tmp.4lL6wQPEf9/.config/geeqie/layouts'
removed '/tmp/tmp.4lL6wQPEf9/.config/geeqie/marks'
removed '/tmp/tmp.4lL6wQPEf9/.config/geeqie/geeqierc.xml'
removed '/tmp/tmp.4lL6wQPEf9/.config/geeqie/history'
removed '/tmp/tmp.4lL6wQPEf9/.config/geeqie/accels'
removed directory '/tmp/tmp.4lL6wQPEf9/.config/geeqie'
removed directory '/tmp/tmp.4lL6wQPEf9/.config/ibus/bus'
removed directory '/tmp/tmp.4lL6wQPEf9/.config/ibus'
removed directory '/tmp/tmp.4lL6wQPEf9/.config'
removed directory '/tmp/tmp.4lL6wQPEf9/.local/share/geeqie/collections'
removed directory '/tmp/tmp.4lL6wQPEf9/.local/share/geeqie/metadata'
removed directory '/tmp/tmp.4lL6wQPEf9/.local/share/geeqie'
removed directory '/tmp/tmp.4lL6wQPEf9/.local/share'
removed directory '/tmp/tmp.4lL6wQPEf9/.local'
removed directory '/tmp/tmp.4lL6wQPEf9/.cache/geeqie/thumbnails'
removed directory '/tmp/tmp.4lL6wQPEf9/.cache/geeqie'
removed directory '/tmp/tmp.4lL6wQPEf9/.cache'
The source for rm
is here: https://github.com/coreutils/coreutils/blob/master/src/remove.c
Importantly, recursive rm
uses a generator that will DFS-traverse the filesystem, but that will emit twice for every directory, first to recurse, and secondly to delete the directory itself. From the source:
/* This function is called once for every file system object that fts
encounters. fts performs a depth-first traversal.
A directory is usually processed twice, first with fts_info == FTS_D,
and later, after all of its entries have been processed, with FTS_DP.
So if a directory is created between the FTS_D
and FTS_DP
phases, we could end up in a situation where rm
refuses to delete it. Alternately, if a file is replaced by a directory (or otherwise changes type), then rm
could attempt to use the wrong syscall to remove the object.
I found that just adding a sleep 1
before rm -rf
causes this to work consistently. Obviously, just sleeping isn't a great solution, and a better option would be to determine when we can expect other processes to have finished modifying the filesystem.
I also found that recursively listing the directory (with ls -laR $TEMP_HOME
) also causes reliable test completion. I don't know whether caching behavior could be involved, or whether it's just that the listing takes long enough for other things to complete.
Setup (please complete the following information):
Describe the bug First noticed by @caclark after my
isolate-test.sh
simplification in https://github.com/BestImageViewer/geeqie/commit/59b915e64301e4169c3fac15c153183b5705d5e2When the
xdg-desktop-portal
package is not installed, the image tests work fine. When that package is installed, the tests fail.To reproduce
Unexpected behavior
Here's another example, with a different-seeming failure mode:
Expected behavior Without
xdg-desktop-portal
installed, these two look like the following:And the JPG test: