avoid using removePathForcibly everywhere, it is unsafe

If the temp directory can somehow contain a hard link, it changes the
mode, which affects all other hard linked files. So, it's too unsafe
to use everywhere in git-annex, since hard links are possible in
multiple ways and it would be very hard to prove that every place that
uses a temp directory cannot possibly put a hard link in it.

Added a call to removeDirectoryForCleanup to test_crypto, which will
fix the problem that commit 17b20a2450
was intending to fix, with a much smaller hammer.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-05-02 14:06:20 -04:00
parent 1b02cd4715
commit 642703c7e4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 40 additions and 8 deletions

View file

@ -69,11 +69,4 @@ removeTmpDir tmpdir = liftIO $ whenM (doesDirectoryExist tmpdir) $ do
go tmpdir
#endif
where
-- Use removePathForcibly when available, to avoid crashing
-- if some other process is removing files in the directory at the
-- same time.
#if MIN_VERSION_directory(1,2,7)
go = removePathForcibly
#else
go = removeDirectoryRecursive
#endif