Both fs::remove_all and shutil::rmtree() are a bit dangerous, and most of their uses are not necessary, this PR removes most instances of both.
remove_all() is still used in in src/test/util/setup_common.cpp in BasicTestingSetup::BasicTestingSetup’s constructor and destructor, and in src/test/kernel/test_kernel.cpp’s TestDirectory:
In both cases, remove_all is likely necessary, but because the kernel test code’s is RAII, it is much easier to reason about, maybe in a followup or future change BasicTestingSetup could be improved.
Similarly in the python code, most usage was unnecessary, but there are a few places where rmtree() was necessary, I have added sanity checks to make sure these are inside of the tmpdir before doing recursive delete there.