| Git.repoIsLocal r = True
| Git.repoIsLocalUnknown r = True
| otherwise = False
- sync currentbranch@(Just _, _) = do
+ syncbranch currentbranch@(Just _, _) = do
(failedpull, diverged) <- manualPull currentbranch =<< gitremotes
now <- liftIO getCurrentTime
failedpush <- pushToRemotes' now =<< gitremotes
return (nub $ failedpull ++ failedpush, diverged)
{- No local branch exists yet, but we can try pulling. -}
- sync (Nothing, _) = manualPull (Nothing, Nothing) =<< gitremotes
+ syncbranch (Nothing, _) = manualPull (Nothing, Nothing) =<< gitremotes
go = do
- (failed, diverged) <- sync =<< liftAnnex getCurrentBranch
+ (failed, diverged) <- syncbranch =<< liftAnnex getCurrentBranch
addScanRemotes diverged =<<
filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) rs
return failed
Anything still relying on that, eg via cabal v1-install will need to
change to using make install-home.a
* git-annex.cabal: Support building with unix-compat 0.7
+ * Support building with unix-2.8.0.
-- Joey Hess <id@joeyh.name> Mon, 26 Jun 2023 13:10:40 -0400
import Utility.Daemon
#ifndef mingw32_HOST_OS
import Annex.Path
+import Utility.OpenFd
#endif
cmd :: Command
#ifndef mingw32_HOST_OS
git_annex <- liftIO programPath
ps <- gitAnnexDaemonizeParams
- let logfd = openFd "/dev/null" ReadOnly Nothing defaultFileFlags
+ let logfd = openFdWithMode (toRawFilePath "/dev/null") ReadOnly Nothing defaultFileFlags
liftIO $ daemonize git_annex ps logfd Nothing False runNonInteractive
#else
liftIO $ foreground Nothing runNonInteractive
import Common
#ifndef mingw32_HOST_OS
+import Utility.OpenFd
import System.Posix.Types
import System.Posix.IO
#else
openLock' lck = do
#ifndef mingw32_HOST_OS
-- On unix, git simply uses O_EXCL
- h <- openFd lck ReadWrite (Just 0O666)
+ h <- openFdWithMode (toRawFilePath lck) ReadWrite (Just 0O666)
(defaultFileFlags { exclusive = True })
setFdOption h CloseOnExec True
#else
import Utility.FileMode
import Utility.Directory.Create
import qualified Utility.RawFilePath as R
+#ifndef mingw32_HOST_OS
+import Utility.OpenFd
+#endif
remote :: RemoteType
remote = specialRemoteType $ RemoteType
#ifndef mingw32_HOST_OS
let open = do
-- Need a duplicate fd for the post check.
- fd <- openFd f' ReadOnly Nothing defaultFileFlags
+ fd <- openFdWithMode f ReadOnly Nothing defaultFileFlags
dupfd <- dup fd
h <- fdToHandle fd
return (h, dupfd)
#ifndef mingw32_HOST_OS
import Utility.LogFile
import Utility.Env
+import Utility.OpenFd
#else
import System.Win32.Process (terminateProcessById)
import Utility.LockFile
maybe noop lockPidFile pidfile
a
_ -> do
- nullfd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
+ nullfd <- openFdWithMode (toRawFilePath "/dev/null") ReadOnly Nothing defaultFileFlags
redir nullfd stdInput
redirLog =<< openlogfd
environ <- getEnvironment
lockPidFile :: FilePath -> IO ()
lockPidFile pidfile = do
#ifndef mingw32_HOST_OS
- fd <- openFd pidfile ReadWrite (Just stdFileMode) defaultFileFlags
+ fd <- openFdWithMode (toRawFilePath pidfile) ReadWrite (Just stdFileMode) defaultFileFlags
locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0)
- fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags
+ fd' <- openFdWithMode (toRawFilePath newfile) ReadWrite (Just stdFileMode) defaultFileFlags
{ trunc = True }
locked' <- catchMaybeIO $ setLock fd' (WriteLock, AbsoluteSeek, 0, 0)
case (locked, locked') of
checkDaemon pidfile = bracket setup cleanup go
where
setup = catchMaybeIO $
- openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags
+ openFdWithMode (toRawFilePath pidfile) ReadOnly (Just stdFileMode) defaultFileFlags
cleanup (Just fd) = closeFd fd
cleanup Nothing = return ()
go (Just fd) = catchDefaultIO Nothing $ do
import Common
import Utility.DirWatcher.Types
+import Utility.OpenFd
import System.Posix.Types
import Foreign.C.Types
Nothing -> walk c rest
Just info -> do
mfd <- catchMaybeIO $
- Posix.openFd dir Posix.ReadOnly Nothing Posix.defaultFileFlags
+ openFdWithMode (toRawFilePath dir) Posix.ReadOnly Nothing Posix.defaultFileFlags
case mfd of
Nothing -> walk c rest
Just fd -> do
import Utility.Monad
import Utility.Path.AbsRel
import Utility.FileMode
+import Utility.OpenFd
import Utility.LockFile.LockStatus
import Utility.ThreadScheduler
import Utility.Hash
)
Left _ -> catchMaybeIO $ do
let setup = do
- fd <- openFd dest WriteOnly
+ fd <- openFdWithMode dest WriteOnly
(Just $ combineModes readModes)
(defaultFileFlags {exclusive = True})
fdToHandle fd
import Utility.Applicative
import Utility.FileMode
import Utility.LockFile.LockStatus
+import Utility.OpenFd
import System.IO
import System.Posix.Types
openLockFile :: LockRequest -> Maybe ModeSetter -> LockFile -> IO Fd
openLockFile lockreq filemode lockfile = do
l <- applyModeSetter filemode lockfile $ \filemode' ->
- openFd lockfile openfor filemode' defaultFileFlags
+ openFdWithMode lockfile openfor filemode' defaultFileFlags
setFdOption l CloseOnExec True
return l
where
--- /dev/null
+{- openFd wrapper to support old versions of unix package.
+ -
+ - Copyright 2023 Joey Hess <id@joeyh.name>
+ -
+ - License: BSD-2-clause
+ -}
+
+{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -fno-warn-tabs #-}
+
+module Utility.OpenFd (
+ openFdWithMode,
+) where
+
+import System.Posix.IO.ByteString
+import System.Posix.Types
+import System.FilePath.ByteString (RawFilePath)
+
+openFdWithMode :: RawFilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
+#if MIN_VERSION_unix(2,8,0)
+openFdWithMode f openmode filemode flags =
+ openFd f openmode (flags { creat = filemode })
+#else
+openFdWithMode = openFd
+#endif
import Network.URI
import Network.HTTP.Types
-import qualified Network.Connection as NC
import qualified Data.CaseInsensitive as CI
import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as B8
case partitionEithers (map checkrestriction addrs) of
((e:_es), []) -> throwIO e
(_, as)
- | null as -> throwIO $
- NC.HostNotResolved hostname
+ | null as -> giveup $
+ "cannot resolve host " ++ hostname
| otherwise -> return $
(limitresolve p) as ++ ps
checkrestriction addr = maybe (Right addr) Left $
Utility.MoveFile
Utility.Network
Utility.NotificationBroadcaster
+ Utility.OpenFd
Utility.OptParse
Utility.OSX
Utility.PID