summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-25 17:37:09 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-25 17:37:09 -0400
commitc46b6bef8820ef3295bce3374c1afb90a6725557 (patch)
tree441fbaa382fac333529b6a77101900fd471cdb41 /Command/Fsck.hs
parent36feacc1ea527d28bcedc87ae8a537c9990c7bb6 (diff)
Support building without persistent database on for systems that lack TH. This removes support for incremental fsck.
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs33
1 files changed, 30 insertions, 3 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 0e0c49d78..a201c4519 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -30,12 +30,15 @@ import Annex.UUID
import Utility.DataUnits
import Config
import Types.Key
-import Types.CleanupActions
import Utility.HumanTime
import Utility.CopyFile
import Git.FilePath
import Utility.PID
+
+#ifdef WITH_DATABASE
import qualified Database.Fsck as FsckDb
+import Types.CleanupActions
+#endif
import Data.Time.Clock.POSIX
import System.Posix.Types (EpochTime)
@@ -91,7 +94,7 @@ seek o = do
(\k -> startKey i k =<< getNumCopies)
(withFilesInGit $ whenAnnexed $ start from i)
(fsckFiles o)
- withFsckDb i FsckDb.closeDb
+ cleanupIncremental i
void $ tryIO $ recordActivity Fsck u
start :: Maybe Remote -> Incremental -> FilePath -> Key -> CommandStart
@@ -454,16 +457,24 @@ runFsck inc file key a = ifM (needFsck inc key)
{- Check if a key needs to be fscked, with support for incremental fscks. -}
needFsck :: Incremental -> Key -> Annex Bool
+#ifdef WITH_DATABASE
needFsck (ContIncremental h) key = liftIO $ not <$> FsckDb.inDb h key
+#endif
needFsck _ _ = return True
+#ifdef WITH_DATABASE
withFsckDb :: Incremental -> (FsckDb.FsckHandle -> Annex ()) -> Annex ()
withFsckDb (ContIncremental h) a = a h
withFsckDb (StartIncremental h) a = a h
withFsckDb NonIncremental _ = noop
+#endif
recordFsckTime :: Incremental -> Key -> Annex ()
+#ifdef WITH_DATABASE
recordFsckTime inc key = withFsckDb inc $ \h -> liftIO $ FsckDb.addDb h key
+#else
+recordFsckTime _ _ = return ()
+#endif
{- Records the start time of an incremental fsck.
-
@@ -512,10 +523,16 @@ getStartTime u = do
fromfile >= fromstatus
#endif
-data Incremental = StartIncremental FsckDb.FsckHandle | ContIncremental FsckDb.FsckHandle | NonIncremental
+data Incremental
+ = NonIncremental
+#ifdef WITH_DATABASE
+ | StartIncremental FsckDb.FsckHandle
+ | ContIncremental FsckDb.FsckHandle
+#endif
prepIncremental :: UUID -> Maybe IncrementalOpt -> Annex Incremental
prepIncremental _ Nothing = pure NonIncremental
+#ifdef WITH_DATABASE
prepIncremental u (Just StartIncrementalO) = do
recordStartTime u
ifM (FsckDb.newPass u)
@@ -537,3 +554,13 @@ prepIncremental u (Just (ScheduleIncrementalO delta)) = do
prepIncremental u $ Just $ case started of
Nothing -> StartIncrementalO
Just _ -> MoreIncrementalO
+#else
+prepIncremental _ _ = error "This git-annex was not built with database support; incremental fsck not supported"
+#endif
+
+cleanupIncremental :: Incremental -> Annex ()
+#ifdef WITH_DATABASE
+cleanupIncremental i = withFsckDb i FsckDb.closeDb
+#else
+cleanupIncremental _ = return ()
+#endif