Changed to use IO Exceptions

This commit is contained in:
James Hobson 2022-01-12 13:31:10 +01:00
parent 5d43168370
commit 3fd9fae66a
No known key found for this signature in database
GPG Key ID: F26F0E100770F597

View File

@ -888,17 +888,18 @@ applyPatches :: (MonadReader env m, HasDirs env, HasLog env, MonadIO m)
-> FilePath -- ^ dir to apply patches in -> FilePath -- ^ dir to apply patches in
-> Excepts '[PatchFailed] m () -> Excepts '[PatchFailed] m ()
applyPatches pdir ddir = do applyPatches pdir ddir = do
seriesExists <- liftIO (doesFileExist (pdir </> "series")) let lexicographical = (fmap . fmap) (pdir </>) $ sort <$> findFiles
patches <- if seriesExists
then
liftIO $ map (pdir </>) . lines <$> readFile (pdir </> "series")
else
(fmap . fmap) (pdir </>) $ liftIO $ sort <$> findFiles
pdir pdir
(makeRegexOpts compExtended (makeRegexOpts compExtended
execBlank execBlank
([s|.+\.(patch|diff)$|] :: ByteString) ([s|.+\.(patch|diff)$|] :: ByteString)
) )
let quilt = map (pdir </>) . lines <$> readFile (pdir </> "series")
patches <- liftIO $ quilt `catchIO` (\e ->
if isDoesNotExistError e || isPermissionError e then
lexicographical
else throwIO e)
forM_ patches $ \patch' -> applyPatch patch' ddir forM_ patches $ \patch' -> applyPatch patch' ddir