squash compiler warnings on Windows

This commit is contained in:
Joey Hess 2013-08-04 13:12:18 -04:00
parent 6a97896b47
commit 06db8e0bd9
8 changed files with 33 additions and 13 deletions

View file

@ -48,12 +48,14 @@ import Types.Key
import Utility.DataUnits import Utility.DataUnits
import Utility.CopyFile import Utility.CopyFile
import Config import Config
import Annex.Exception
import Git.SharedRepository import Git.SharedRepository
import Annex.Perms import Annex.Perms
import Annex.Link import Annex.Link
import Annex.Content.Direct import Annex.Content.Direct
import Annex.ReplaceFile import Annex.ReplaceFile
#ifndef mingw32_HOST_OS
import Annex.Exception
#endif
{- Checks if a given key's content is currently present. -} {- Checks if a given key's content is currently present. -}
inAnnex :: Key -> Annex Bool inAnnex :: Key -> Annex Bool
@ -91,34 +93,34 @@ inAnnexSafe :: Key -> Annex (Maybe Bool)
inAnnexSafe = inAnnex' (fromMaybe False) (Just False) go inAnnexSafe = inAnnex' (fromMaybe False) (Just False) go
where where
go f = liftIO $ openforlock f >>= check go f = liftIO $ openforlock f >>= check
openforlock f = catchMaybeIO $
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
openforlock f = catchMaybeIO $
openFd f ReadOnly Nothing defaultFileFlags openFd f ReadOnly Nothing defaultFileFlags
#else #else
return () openforlock _ = return $ Just ()
#endif #endif
check Nothing = return is_missing check Nothing = return is_missing
check (Just h) = do
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
check (Just h) = do
v <- getLock h (ReadLock, AbsoluteSeek, 0, 0) v <- getLock h (ReadLock, AbsoluteSeek, 0, 0)
closeFd h closeFd h
return $ case v of return $ case v of
Just _ -> is_locked Just _ -> is_locked
Nothing -> is_unlocked Nothing -> is_unlocked
#else #else
return is_unlocked check (Just _) = return is_unlocked
#endif #endif
#ifndef mingw32_HOST_OS
is_locked = Nothing is_locked = Nothing
#endif
is_unlocked = Just True is_unlocked = Just True
is_missing = Just False is_missing = Just False
{- Content is exclusively locked while running an action that might remove {- Content is exclusively locked while running an action that might remove
- it. (If the content is not present, no locking is done.) -} - it. (If the content is not present, no locking is done.) -}
lockContent :: Key -> Annex a -> Annex a lockContent :: Key -> Annex a -> Annex a
lockContent key a = do #ifndef mingw32_HOST_OS
#ifdef mingw32_HOST_OS lockContent key a =
a
#else
file <- calcRepo $ gitAnnexLocation key file <- calcRepo $ gitAnnexLocation key
bracketIO (openforlock file >>= lock) unlock (const a) bracketIO (openforlock file >>= lock) unlock (const a)
where where
@ -140,6 +142,8 @@ lockContent key a = do
Right _ -> return $ Just fd Right _ -> return $ Just fd
unlock Nothing = noop unlock Nothing = noop
unlock (Just l) = closeFd l unlock (Just l) = closeFd l
#else
lockContent _key a = a -- no locking for Windows!
#endif #endif
{- Runs an action, passing it a temporary filename to get, {- Runs an action, passing it a temporary filename to get,

View file

@ -14,7 +14,9 @@ import System.Posix.Types (Fd)
import Common.Annex import Common.Annex
import Annex import Annex
#ifndef mingw32_HOST_OS
import Annex.Perms import Annex.Perms
#endif
{- Create a specified lock file, and takes a shared lock. -} {- Create a specified lock file, and takes a shared lock. -}
lockFile :: FilePath -> Annex () lockFile :: FilePath -> Annex ()

View file

@ -19,11 +19,13 @@ import Data.Hash.MD5
import Common.Annex import Common.Annex
import Annex.LockPool import Annex.LockPool
import Annex.Perms
import qualified Build.SysConfig as SysConfig import qualified Build.SysConfig as SysConfig
import qualified Annex import qualified Annex
import Config import Config
import Utility.Env import Utility.Env
#ifndef mingw32_HOST_OS
import Annex.Perms
#endif
{- Generates parameters to ssh to a given host (or user@host) on a given {- Generates parameters to ssh to a given host (or user@host) on a given
- port, with connection caching. -} - port, with connection caching. -}

View file

@ -15,7 +15,9 @@ import Utility.FileMode
import Crypto import Crypto
import Types.Remote (RemoteConfig, RemoteConfigKey) import Types.Remote (RemoteConfig, RemoteConfigKey)
import Remote.Helper.Encryptable (remoteCipher, embedCreds) import Remote.Helper.Encryptable (remoteCipher, embedCreds)
#ifndef mingw32_HOST_OS
import Utility.Env (setEnv) import Utility.Env (setEnv)
#endif
import System.Environment import System.Environment
import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy.Char8 as L

2
Git.hs
View file

@ -38,7 +38,9 @@ import System.Posix.Files
import Common import Common
import Git.Types import Git.Types
#ifndef mingw32_HOST_OS
import Utility.FileMode import Utility.FileMode
#endif
{- User-visible description of a git repo. -} {- User-visible description of a git repo. -}
repoDescribe :: Repo -> String repoDescribe :: Repo -> String

View file

@ -35,9 +35,11 @@ import Utility.DataUnits
import Text.Regex.TDFA import Text.Regex.TDFA
import Text.Regex.TDFA.String import Text.Regex.TDFA.String
#else #else
#ifndef mingw32_HOST_OS
import System.Path.WildMatch import System.Path.WildMatch
import Types.FileMatcher import Types.FileMatcher
#endif #endif
#endif
type MatchFiles = AssumeNotPresent -> FileInfo -> Annex Bool type MatchFiles = AssumeNotPresent -> FileInfo -> Annex Bool
type MkLimit = String -> Either String MatchFiles type MkLimit = String -> Either String MatchFiles

View file

@ -17,7 +17,6 @@ import qualified Data.Map as M
import Control.Exception.Extensible import Control.Exception.Extensible
import Common.Annex import Common.Annex
import Utility.CopyFile
import Utility.Rsync import Utility.Rsync
import Remote.Helper.Ssh import Remote.Helper.Ssh
import Annex.Ssh import Annex.Ssh
@ -44,6 +43,9 @@ import Types.Key
import qualified Fields import qualified Fields
import Logs.Location import Logs.Location
import Utility.Metered import Utility.Metered
#ifndef mingw32_HOST_OS
import Utility.CopyFile
#endif
import Control.Concurrent import Control.Concurrent
import Control.Concurrent.MSampleVar import Control.Concurrent.MSampleVar
@ -360,8 +362,8 @@ copyFromRemote' r key file dest
bracketIO noop (const $ tryIO $ killThread tid) (const $ a feeder) bracketIO noop (const $ tryIO $ killThread tid) (const $ a feeder)
copyFromRemoteCheap :: Remote -> Key -> FilePath -> Annex Bool copyFromRemoteCheap :: Remote -> Key -> FilePath -> Annex Bool
copyFromRemoteCheap r key file
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
copyFromRemoteCheap r key file
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) False $ do | not $ Git.repoIsUrl (repo r) = guardUsable (repo r) False $ do
loc <- liftIO $ gitAnnexLocation key (repo r) $ loc <- liftIO $ gitAnnexLocation key (repo r) $
fromJust $ remoteGitConfig $ gitconfig r fromJust $ remoteGitConfig $ gitconfig r
@ -371,8 +373,10 @@ copyFromRemoteCheap r key file
( copyFromRemote' r key Nothing file ( copyFromRemote' r key Nothing file
, return False , return False
) )
#endif
| otherwise = return False | otherwise = return False
#else
copyFromRemoteCheap _ _ _ = return False
#endif
{- Tries to copy a key's content to a remote's annex. -} {- Tries to copy a key's content to a remote's annex. -}
copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool

View file

@ -15,7 +15,9 @@ import Common.Annex
import Types.Remote import Types.Remote
import qualified Annex import qualified Annex
import Annex.LockPool import Annex.LockPool
#ifndef mingw32_HOST_OS
import Annex.Perms import Annex.Perms
#endif
{- Modifies a remote's access functions to first run the {- Modifies a remote's access functions to first run the
- annex-start-command hook, and trigger annex-stop-command on shutdown. - annex-start-command hook, and trigger annex-stop-command on shutdown.