summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-25 14:09:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-25 14:48:50 -0400
commitf55d91cc91eec2debf4bb013ff2f5201ea1474ea (patch)
tree8b8701608fef4f49622018f26706ebd46bfae943
parentc3aaa702c8fe4424dacfddfc255fca8d6149ad06 (diff)
fix all remaining -Wall warnings on Windows
-rw-r--r--Assistant.hs19
-rw-r--r--Assistant/Threads/SanityChecker.hs10
-rw-r--r--Assistant/Threads/Watcher.hs4
-rw-r--r--Command/Add.hs8
-rw-r--r--Command/Fsck.hs22
-rw-r--r--Git/Command.hs3
-rw-r--r--Git/Queue.hs11
-rw-r--r--Utility/LogFile.hs2
-rw-r--r--Utility/Path.hs1
-rw-r--r--Utility/WebApp.hs5
-rw-r--r--Utility/WinProcess.hs4
11 files changed, 49 insertions, 40 deletions
diff --git a/Assistant.hs b/Assistant.hs
index c66a1b73b..db6fc850c 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -49,11 +49,13 @@ import Assistant.Threads.XMPPPusher
import Assistant.Types.UrlRenderer
#endif
import qualified Utility.Daemon
-import Utility.LogFile
import Utility.ThreadScheduler
import Utility.HumanTime
-import Annex.Perms
import qualified Build.SysConfig as SysConfig
+#ifndef mingw32_HOST_OS
+import Utility.LogFile
+import Annex.Perms
+#endif
import System.Log.Logger
import Network.Socket (HostName)
@@ -70,8 +72,8 @@ startDaemon :: Bool -> Bool -> Maybe Duration -> Maybe String -> Maybe HostName
startDaemon assistant foreground startdelay cannotrun listenhost startbrowser = do
Annex.changeState $ \s -> s { Annex.daemon = True }
pidfile <- fromRepo gitAnnexPidFile
- logfile <- fromRepo gitAnnexLogFile
#ifndef mingw32_HOST_OS
+ logfile <- fromRepo gitAnnexLogFile
createAnnexDirectory (parentDir logfile)
logfd <- liftIO $ openLog logfile
if foreground
@@ -93,11 +95,12 @@ startDaemon assistant foreground startdelay cannotrun listenhost startbrowser =
start (Utility.Daemon.daemonize logfd (Just pidfile) False) Nothing
#else
-- Windows is always foreground, and has no log file.
- liftIO $ Utility.Daemon.lockPidFile pidfile
- start id $ do
- case startbrowser of
- Nothing -> Nothing
- Just a -> Just $ a Nothing Nothing
+ when (foreground || not foreground) $ do
+ liftIO $ Utility.Daemon.lockPidFile pidfile
+ start id $ do
+ case startbrowser of
+ Nothing -> Nothing
+ Just a -> Just $ a Nothing Nothing
#endif
where
desc
diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs
index b94d010e3..d7fe366e2 100644
--- a/Assistant/Threads/SanityChecker.hs
+++ b/Assistant/Threads/SanityChecker.hs
@@ -27,7 +27,6 @@ import qualified Git.Command
import qualified Git.Config
import Utility.ThreadScheduler
import qualified Assistant.Threads.Watcher as Watcher
-import Utility.LogFile
import Utility.Batch
import Utility.NotificationBroadcaster
import Config
@@ -43,6 +42,9 @@ import qualified Annex
#ifdef WITH_WEBAPP
import Assistant.WebApp.Types
#endif
+#ifndef mingw32_HOST_OS
+import Utility.LogFile
+#endif
import Data.Time.Clock.POSIX
import qualified Data.Text as T
@@ -214,10 +216,10 @@ checkLogSize n = do
checkLogSize $ n + 1
where
filesize f = fromIntegral . fileSize <$> liftIO (getFileStatus f)
-#endif
-oneMegabyte :: Int
-oneMegabyte = 1000000
+ oneMegabyte :: Int
+ oneMegabyte = 1000000
+#endif
oneHour :: Int
oneHour = 60 * 60
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 50a0efdd5..611eca1a7 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -23,7 +23,6 @@ import Assistant.Types.Changes
import Assistant.Alert
import Utility.DirWatcher
import Utility.DirWatcher.Types
-import qualified Utility.Lsof as Lsof
import qualified Annex
import qualified Annex.Queue
import qualified Git
@@ -40,6 +39,9 @@ import Annex.ReplaceFile
import Git.Types
import Config
import Utility.ThreadScheduler
+#ifndef mingw32_HOST_OS
+import qualified Utility.Lsof as Lsof
+#endif
import Data.Bits.Utils
import Data.Typeable
diff --git a/Command/Add.hs b/Command/Add.hs
index 662ce4242..ea4933748 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -218,15 +218,15 @@ link file key mcache = flip catchAnnex (undo file key) $ do
l <- inRepo $ gitAnnexLink file key
replaceFile file $ makeAnnexLink l
-#ifdef WITH_CLIBS
-#ifndef __ANDROID__
-- touch symlink to have same time as the original file,
-- as provided in the InodeCache
case mcache of
+#if defined(WITH_CLIBS) && ! defined(__ANDROID__)
Just c -> liftIO $ touch file (TimeSpec $ inodeCacheToMtime c) False
- Nothing -> noop
-#endif
+#else
+ Just _ -> noop
#endif
+ Nothing -> noop
return l
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 6cf444967..a30e895d0 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -466,7 +466,8 @@ getFsckTime key = do
- To guard against time stamp damange (for example, if an annex directory
- is copied without -a), the fsckstate file contains a time that should
- be identical to its modification time.
- - (This is not possible to do on Windows.)
+ - (This is not possible to do on Windows, and so the timestamp in
+ - the file will only be equal or greater than the modification time.)
-}
recordStartTime :: Annex ()
recordStartTime = do
@@ -477,10 +478,10 @@ recordStartTime = do
withFile f WriteMode $ \h -> do
#ifndef mingw32_HOST_OS
t <- modificationTime <$> getFileStatus f
- hPutStr h $ showTime $ realToFrac t
#else
- noop
+ t <- getPOSIXTime
#endif
+ hPutStr h $ showTime $ realToFrac t
where
showTime :: POSIXTime -> String
showTime = show
@@ -494,15 +495,18 @@ getStartTime = do
f <- fromRepo gitAnnexFsckState
liftIO $ catchDefaultIO Nothing $ do
timestamp <- modificationTime <$> getFileStatus f
-#ifndef mingw32_HOST_OS
- t <- readishTime <$> readFile f
- return $ if Just (realToFrac timestamp) == t
+ let fromstatus = Just (realToFrac timestamp)
+ fromfile <- readishTime <$> readFile f
+ return $ if matchingtimestamp fromfile fromstatus
then Just timestamp
else Nothing
-#else
- return $ Just timestamp
-#endif
where
readishTime :: String -> Maybe POSIXTime
readishTime s = utcTimeToPOSIXSeconds <$>
parseTime defaultTimeLocale "%s%Qs" s
+ matchingtimestamp fromfile fromstatus =
+#ifndef mingw32_HOST_OS
+ fromfile == fromstatus
+#else
+ fromfile >= fromstatus
+#endif
diff --git a/Git/Command.hs b/Git/Command.hs
index 0fa3d1b3b..a0c7c4b2a 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -15,9 +15,6 @@ import Common
import Git
import Git.Types
import qualified Utility.CoProcess as CoProcess
-#ifdef mingw32_HOST_OS
-import Git.FilePath
-#endif
import Utility.Batch
{- Constructs a git command line operating on the specified repo. -}
diff --git a/Git/Queue.hs b/Git/Queue.hs
index 9bb7f77d1..7f8724c8d 100644
--- a/Git/Queue.hs
+++ b/Git/Queue.hs
@@ -17,16 +17,17 @@ module Git.Queue (
flush,
) where
-import qualified Data.Map as M
-import System.IO
-import System.Process
-
import Utility.SafeCommand
import Common
import Git
import Git.Command
import qualified Git.UpdateIndex
+import qualified Data.Map as M
+#ifndef mingw32_HOST_OS
+import System.Process
+#endif
+
{- Queable actions that can be performed in a git repository.
-}
data Action
@@ -149,6 +150,7 @@ runAction repo (UpdateIndexAction streamers) =
Git.UpdateIndex.streamUpdateIndex repo $ reverse streamers
runAction repo action@(CommandAction {}) =
#ifndef mingw32_HOST_OS
+ let p = (proc "xargs" $ "-0":"git":toCommand gitparams) { env = gitEnv repo }
withHandle StdinHandle createProcessSuccess p $ \h -> do
fileEncoding h
hPutStr h $ intercalate "\0" $ toCommand $ getFiles action
@@ -162,6 +164,5 @@ runAction repo action@(CommandAction {}) =
void $ boolSystem "git" (gitparams ++ [f])
#endif
where
- p = (proc "xargs" $ "-0":"git":toCommand gitparams) { env = gitEnv repo }
gitparams = gitCommandLine
(Param (getSubcommand action):getParams action) repo
diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs
index 4e76116ba..73fbf820e 100644
--- a/Utility/LogFile.hs
+++ b/Utility/LogFile.hs
@@ -11,7 +11,9 @@ module Utility.LogFile where
import Common
+#ifndef mingw32_HOST_OS
import System.Posix.Types
+#endif
#ifndef mingw32_HOST_OS
openLog :: FilePath -> IO Fd
diff --git a/Utility/Path.hs b/Utility/Path.hs
index e22d0c3f7..570350d61 100644
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -18,7 +18,6 @@ import Data.Char
import Control.Applicative
#ifdef mingw32_HOST_OS
-import Data.Char
import qualified System.FilePath.Posix as Posix
#else
import System.Posix.Files
diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs
index f92c21e4e..6318abdcf 100644
--- a/Utility/WebApp.hs
+++ b/Utility/WebApp.hs
@@ -23,7 +23,6 @@ import Network.HTTP.Types
import System.Log.Logger
import qualified Data.CaseInsensitive as CI
import Network.Socket
-import Control.Exception
import "crypto-api" Crypto.Random
import qualified Web.ClientSession as CS
import qualified Data.ByteString.Lazy as L
@@ -39,6 +38,10 @@ import Control.Concurrent
#ifdef __ANDROID__
import Data.Endian
#endif
+#if defined(__ANDROID__) || defined (mingw32_HOST_OS)
+#else
+import Control.Exception (bracketOnError)
+#endif
localhost :: HostName
localhost = "localhost"
diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs
index 5c6d4cfce..7a566dcba 100644
--- a/Utility/WinProcess.hs
+++ b/Utility/WinProcess.hs
@@ -11,9 +11,5 @@ module Utility.WinProcess where
import Utility.PID
-import System.Win32.Process
-import Foreign.C
-import Control.Exception
-
foreign import ccall unsafe "terminatepid"
terminatePID :: PID -> IO ()