aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex/Branch.hs2
-rw-r--r--Annex/Content.hs2
-rw-r--r--Annex/Journal.hs4
-rw-r--r--Annex/Ssh.hs2
-rw-r--r--Assistant/DaemonStatus.hs2
-rw-r--r--Assistant/Pairing/MakeRemote.hs6
-rw-r--r--Build/InstallDesktopFile.hs2
-rw-r--r--Git/Command.hs2
-rw-r--r--Git/Construct.hs2
-rw-r--r--GitAnnexShell.hs2
-rw-r--r--Locations/UserConfig.hs2
-rw-r--r--Logs/Transfer.hs5
-rw-r--r--Upgrade/V1.hs3
-rw-r--r--Upgrade/V2.hs2
-rw-r--r--Utility/Directory.hs2
-rw-r--r--Utility/Exception.hs8
-rw-r--r--Utility/FreeDesktop.hs3
-rw-r--r--Utility/TempFile.hs4
18 files changed, 29 insertions, 26 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index 1272bd95f..e74ab3a29 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -322,7 +322,7 @@ needUpdateIndex :: Git.Ref -> Annex Bool
needUpdateIndex branchref = do
lock <- fromRepo gitAnnexIndexLock
lockref <- Git.Ref . firstLine <$>
- liftIO (catchDefaultIO (readFileStrict lock) "")
+ liftIO (catchDefaultIO "" $ readFileStrict lock)
return (lockref /= branchref)
{- Record that the branch's index has been updated to correspond to a
diff --git a/Annex/Content.hs b/Annex/Content.hs
index fab27d88a..e6afd5465 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -280,7 +280,7 @@ getKeysPresent :: Annex [Key]
getKeysPresent = liftIO . traverse (2 :: Int) =<< fromRepo gitAnnexObjectDir
where
traverse depth dir = do
- contents <- catchDefaultIO (dirContents dir) []
+ contents <- catchDefaultIO [] (dirContents dir)
if depth == 0
then continue (mapMaybe (fileKey . takeFileName) contents) []
else do
diff --git a/Annex/Journal.hs b/Annex/Journal.hs
index ff103180e..4a56ce3e3 100644
--- a/Annex/Journal.hs
+++ b/Annex/Journal.hs
@@ -47,8 +47,8 @@ getJournalledFiles = map fileJournal <$> getJournalFiles
getJournalFiles :: Annex [FilePath]
getJournalFiles = do
g <- gitRepo
- fs <- liftIO $
- catchDefaultIO (getDirectoryContents $ gitAnnexJournalDir g) []
+ fs <- liftIO $ catchDefaultIO [] $
+ getDirectoryContents $ gitAnnexJournalDir g
return $ filter (`notElem` [".", ".."]) fs
{- Checks if there are changes in the journal. -}
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 46885393c..a0aae2b7e 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -71,7 +71,7 @@ sshCleanup :: Annex ()
sshCleanup = do
dir <- fromRepo gitAnnexSshDir
sockets <- filter (not . isLock) <$>
- liftIO (catchDefaultIO (dirContents dir) [])
+ liftIO (catchDefaultIO [] $ dirContents dir)
forM_ sockets cleanup
where
cleanup socketfile = do
diff --git a/Assistant/DaemonStatus.hs b/Assistant/DaemonStatus.hs
index cbd606680..11ea8676d 100644
--- a/Assistant/DaemonStatus.hs
+++ b/Assistant/DaemonStatus.hs
@@ -108,7 +108,7 @@ startDaemonStatus :: Annex DaemonStatusHandle
startDaemonStatus = do
file <- fromRepo gitAnnexDaemonStatusFile
status <- liftIO $
- catchDefaultIO (readDaemonStatusFile file) =<< newDaemonStatus
+ flip catchDefaultIO (readDaemonStatusFile file) =<< newDaemonStatus
transfers <- M.fromList <$> getTransfers
remotes <- calcKnownRemotes
liftIO $ atomically $ newTMVar status
diff --git a/Assistant/Pairing/MakeRemote.hs b/Assistant/Pairing/MakeRemote.hs
index f3c5e0d50..fae8c5ee3 100644
--- a/Assistant/Pairing/MakeRemote.hs
+++ b/Assistant/Pairing/MakeRemote.hs
@@ -78,7 +78,8 @@ bestHostName :: PairMsg -> IO HostName
bestHostName msg = case remoteHostName $ pairMsgData msg of
Just h -> do
let localname = h ++ ".local"
- addrs <- catchDefaultIO (getAddrInfo Nothing (Just localname) Nothing) []
+ addrs <- catchDefaultIO [] $
+ getAddrInfo Nothing (Just localname) Nothing
maybe fallback (const $ return localname) (headMaybe addrs)
Nothing -> fallback
where
@@ -88,4 +89,5 @@ bestHostName msg = case remoteHostName $ pairMsgData msg of
IPv4Addr addr -> SockAddrInet (PortNum 0) addr
IPv6Addr addr -> SockAddrInet6 (PortNum 0) 0 addr 0
fromMaybe (showAddr a)
- <$> catchDefaultIO (fst <$> getNameInfo [] True False sockaddr) Nothing
+ <$> catchDefaultIO Nothing
+ (fst <$> getNameInfo [] True False sockaddr)
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
index 035d16016..3f8b980cc 100644
--- a/Build/InstallDesktopFile.hs
+++ b/Build/InstallDesktopFile.hs
@@ -49,7 +49,7 @@ isRoot = do
inDestDir :: FilePath -> IO FilePath
inDestDir f = do
- destdir <- catchDefaultIO (getEnv "DESTDIR") ""
+ destdir <- catchDefaultIO "" (getEnv "DESTDIR")
return $ destdir </> f
writeFDODesktop :: FilePath -> IO ()
diff --git a/Git/Command.hs b/Git/Command.hs
index 431569559..687f6802c 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -79,7 +79,7 @@ pipeNullSplit params repo =
reap :: IO ()
reap = do
-- throws an exception when there are no child processes
- catchDefaultIO (getAnyProcessStatus False True) Nothing
+ catchDefaultIO Nothing (getAnyProcessStatus False True)
>>= maybe noop (const reap)
{- Runs a git command as a coprocess. -}
diff --git a/Git/Construct.hs b/Git/Construct.hs
index ce12f9b66..3c1cfdbdf 100644
--- a/Git/Construct.hs
+++ b/Git/Construct.hs
@@ -224,7 +224,7 @@ checkForRepo dir =
<&&> doesDirectoryExist (dir </> "objects")
gitDirFile = do
c <- firstLine <$>
- catchDefaultIO (readFile $ dir </> ".git") ""
+ catchDefaultIO "" (readFile $ dir </> ".git")
return $ if gitdirprefix `isPrefixOf` c
then Just $ Local
{ gitdir = drop (length gitdirprefix) c
diff --git a/GitAnnexShell.hs b/GitAnnexShell.hs
index 15be51180..d9b60c0f6 100644
--- a/GitAnnexShell.hs
+++ b/GitAnnexShell.hs
@@ -132,5 +132,5 @@ checkNotReadOnly cmd
checkEnv :: String -> IO ()
checkEnv var =
- whenM (not . null <$> catchDefaultIO (getEnv var) "") $
+ whenM (not . null <$> catchDefaultIO "" (getEnv var)) $
error $ "Action blocked by " ++ var
diff --git a/Locations/UserConfig.hs b/Locations/UserConfig.hs
index 5da58eb9f..3a6a27e91 100644
--- a/Locations/UserConfig.hs
+++ b/Locations/UserConfig.hs
@@ -28,4 +28,4 @@ programFile = userConfigFile "program"
readProgramFile :: IO FilePath
readProgramFile = do
programfile <- programFile
- catchDefaultIO (readFile programfile) "git-annex"
+ catchDefaultIO "git-annex" $ readFile programfile
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index a58944a83..a641c4882 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -134,9 +134,8 @@ checkTransfer t = do
liftIO $ closeFd fd
case locked of
Nothing -> return Nothing
- Just (pid, _) -> liftIO $
- flip catchDefaultIO Nothing $
- readTransferInfoFile (Just pid) tfile
+ Just (pid, _) -> liftIO $ catchDefaultIO Nothing $
+ readTransferInfoFile (Just pid) tfile
{- Gets all currently running transfers. -}
getTransfers :: Annex [(Transfer, TransferInfo)]
diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs
index b2f2f38c1..36d06dc48 100644
--- a/Upgrade/V1.hs
+++ b/Upgrade/V1.hs
@@ -180,7 +180,8 @@ writeLog1 :: FilePath -> [LogLine] -> IO ()
writeLog1 file ls = viaTmp writeFile file (showLog ls)
readLog1 :: FilePath -> IO [LogLine]
-readLog1 file = catchDefaultIO (parseLog <$> readFileStrict file) []
+readLog1 file = catchDefaultIO [] $
+ parseLog <$> readFileStrict file
lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend))
lookupFile1 file = do
diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs
index c001bc5a9..1f4a40f3c 100644
--- a/Upgrade/V2.hs
+++ b/Upgrade/V2.hs
@@ -71,7 +71,7 @@ locationLogs = do
files <- mapM tryDirContents (concat levelb)
return $ mapMaybe islogfile (concat files)
where
- tryDirContents d = catchDefaultIO (dirContents d) []
+ tryDirContents d = catchDefaultIO [] $ dirContents d
islogfile f = maybe Nothing (\k -> Just (k, f)) $
logFileKey $ takeFileName f
diff --git a/Utility/Directory.hs b/Utility/Directory.hs
index 057da6087..e6609caf9 100644
--- a/Utility/Directory.hs
+++ b/Utility/Directory.hs
@@ -43,7 +43,7 @@ dirContentsRecursive topdir = dirContentsRecursive' topdir [""]
dirContentsRecursive' :: FilePath -> [FilePath] -> IO [FilePath]
dirContentsRecursive' _ [] = return []
dirContentsRecursive' topdir (dir:dirs) = unsafeInterleaveIO $ do
- (files, dirs') <- collect [] [] =<< catchDefaultIO (dirContents (topdir </> dir)) []
+ (files, dirs') <- collect [] [] =<< catchDefaultIO [] (dirContents (topdir </> dir))
files' <- dirContentsRecursive' topdir (dirs' ++ dirs)
return (files ++ files')
where
diff --git a/Utility/Exception.hs b/Utility/Exception.hs
index a6726945c..8b6077743 100644
--- a/Utility/Exception.hs
+++ b/Utility/Exception.hs
@@ -13,15 +13,15 @@ import Control.Applicative
{- Catches IO errors and returns a Bool -}
catchBoolIO :: IO Bool -> IO Bool
-catchBoolIO a = catchDefaultIO a False
+catchBoolIO a = catchDefaultIO False a
{- Catches IO errors and returns a Maybe -}
catchMaybeIO :: IO a -> IO (Maybe a)
-catchMaybeIO a = catchDefaultIO (Just <$> a) Nothing
+catchMaybeIO a = catchDefaultIO Nothing $ Just <$> a
{- Catches IO errors and returns a default value. -}
-catchDefaultIO :: IO a -> a -> IO a
-catchDefaultIO a def = catchIO a (const $ return def)
+catchDefaultIO :: a -> IO a -> IO a
+catchDefaultIO def a = catchIO a (const $ return def)
{- Catches IO errors and returns the error message. -}
catchMsgIO :: IO a -> IO (Either String a)
diff --git a/Utility/FreeDesktop.hs b/Utility/FreeDesktop.hs
index a1109f729..0845f3329 100644
--- a/Utility/FreeDesktop.hs
+++ b/Utility/FreeDesktop.hs
@@ -123,4 +123,5 @@ userDesktopDir = maybe fallback return =<< (parse <$> xdg_user_dir)
xdgEnvHome :: String -> String -> IO String
xdgEnvHome envbase homedef = do
home <- myHomeDir
- catchDefaultIO (getEnv $ "XDG_" ++ envbase) (home </> homedef)
+ catchDefaultIO (home </> homedef) $
+ getEnv $ "XDG_" ++ envbase
diff --git a/Utility/TempFile.hs b/Utility/TempFile.hs
index 2673d47b0..60feb7408 100644
--- a/Utility/TempFile.hs
+++ b/Utility/TempFile.hs
@@ -34,7 +34,7 @@ withTempFile :: Template -> (FilePath -> Handle -> IO a) -> IO a
withTempFile template a = bracket create remove use
where
create = do
- tmpdir <- catchDefaultIO getTemporaryDirectory "."
+ tmpdir <- catchDefaultIO "." getTemporaryDirectory
openTempFile tmpdir template
remove (name, handle) = do
hClose handle
@@ -48,7 +48,7 @@ withTempDir template = bracket create remove
where
remove = removeDirectoryRecursive
create = do
- tmpdir <- catchDefaultIO getTemporaryDirectory "."
+ tmpdir <- catchDefaultIO "." getTemporaryDirectory
createDirectoryIfMissing True tmpdir
pid <- getProcessID
makedir tmpdir (template ++ show pid) (0 :: Int)