more RawFilePath conversion

nukeFile replaced with removeWhenExistsWith removeLink, which allows
using RawFilePath. Utility.Directory cannot use RawFilePath since setup
does not depend on posix.

This commit was sponsored by Graham Spencer on Patreon.
This commit is contained in:
Joey Hess 2020-10-29 10:33:12 -04:00
parent 8d66f7ba0f
commit e505c03bcc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
51 changed files with 182 additions and 153 deletions

View file

@ -208,9 +208,9 @@ probeCrippledFileSystem' tmp = do
where
probe f = catchDefaultIO (True, []) $ do
let f2 = f ++ "2"
nukeFile f2
removeWhenExistsWith removeLink f2
createSymbolicLink f f2
nukeFile f2
removeWhenExistsWith removeLink f2
preventWrite f
-- Should be unable to write to the file, unless
-- running as root, but some crippled
@ -251,13 +251,13 @@ probeLockSupport = withEventuallyCleanedOtherTmp $ \tmp -> do
liftIO $ withAsync warnstall (const (go f mode))
where
go f mode = do
nukeFile f
removeWhenExistsWith removeLink f
let locktest = bracket
(Posix.lockExclusive (Just mode) f)
Posix.dropLock
(const noop)
ok <- isRight <$> tryNonAsync locktest
nukeFile f
removeWhenExistsWith removeLink f
return ok
warnstall = do
@ -275,14 +275,14 @@ probeFifoSupport = do
let f = tmp </> "gaprobe"
let f2 = tmp </> "gaprobe2"
liftIO $ do
nukeFile f
nukeFile f2
removeWhenExistsWith removeLink f
removeWhenExistsWith removeLink f2
ms <- tryIO $ do
createNamedPipe f ownerReadMode
createLink f f2
getFileStatus f
nukeFile f
nukeFile f2
removeWhenExistsWith removeLink f
removeWhenExistsWith removeLink f2
return $ either (const False) isNamedPipe ms
#endif