]> dgit.raspbian.org Git - git-annex.git/commitdiff
move code from Command.Fsck
authorJoey Hess <joeyh@joeyh.name>
Thu, 13 Jan 2022 17:24:50 +0000 (13:24 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 13 Jan 2022 17:24:50 +0000 (13:24 -0400)
Sponsored-by: Dartmouth College's Datalad project
Annex/Content.hs
Command/Fsck.hs
Command/Migrate.hs

index d56d2f88241a08c2a961edb54dbd13ac66c2c5cb..b7c7f645d856908559abbcc82debed2747ba1cc2 100644 (file)
@@ -59,6 +59,10 @@ module Annex.Content (
        Verification(..),
        unVerified,
        withTmpWorkDir,
+       KeyStatus(..),
+       isKeyUnlockedThin,
+       getKeyStatus,
+       getKeyFileStatus,
 ) where
 
 import System.IO.Unsafe (unsafeInterleaveIO)
@@ -794,3 +798,40 @@ exclude [] _ = [] -- optimisation
 exclude smaller larger = S.toList $ remove larger $ S.fromList smaller
   where
        remove a b = foldl (flip S.delete) b a
+
+data KeyStatus
+       = KeyMissing
+       | KeyPresent
+       | KeyUnlockedThin
+       -- ^ An annex.thin worktree file is hard linked to the object.
+       | KeyLockedThin
+       -- ^ The object has hard links, but the file being fscked
+       -- is not the one that hard links to it.
+       deriving (Show)
+
+isKeyUnlockedThin :: KeyStatus -> Bool
+isKeyUnlockedThin KeyUnlockedThin = True
+isKeyUnlockedThin KeyLockedThin = False
+isKeyUnlockedThin KeyPresent = False
+isKeyUnlockedThin KeyMissing = False
+
+getKeyStatus :: Key -> Annex KeyStatus
+getKeyStatus key = catchDefaultIO KeyMissing $ do
+       afs <- not . null <$> Database.Keys.getAssociatedFiles key
+       obj <- calcRepo (gitAnnexLocation key)
+       multilink <- ((> 1) . linkCount <$> liftIO (R.getFileStatus obj))
+       return $ if multilink && afs
+               then KeyUnlockedThin
+               else KeyPresent
+
+getKeyFileStatus :: Key -> FilePath -> Annex KeyStatus
+getKeyFileStatus key file = do
+       s <- getKeyStatus key
+       case s of
+               KeyUnlockedThin -> catchDefaultIO KeyUnlockedThin $
+                       ifM (isJust <$> isAnnexLink (toRawFilePath file))
+                               ( return KeyLockedThin
+                               , return KeyUnlockedThin
+                               )
+               _ -> return s
+
index b34b3a12f4b6a80e8891da79191b0e8a3f8b05ce..6ab159e10548c40e74cd6d3a34e1ddf54843914b 100644 (file)
@@ -705,39 +705,3 @@ withFsckDb (StartIncremental h) a = a h
 withFsckDb NonIncremental _ = noop
 withFsckDb (ScheduleIncremental _ _ i) a = withFsckDb i a
 
-data KeyStatus
-       = KeyMissing
-       | KeyPresent
-       | KeyUnlockedThin
-       -- ^ An annex.thin worktree file is hard linked to the object.
-       | KeyLockedThin
-       -- ^ The object has hard links, but the file being fscked
-       -- is not the one that hard links to it.
-       deriving (Show)
-
-isKeyUnlockedThin :: KeyStatus -> Bool
-isKeyUnlockedThin KeyUnlockedThin = True
-isKeyUnlockedThin KeyLockedThin = False
-isKeyUnlockedThin KeyPresent = False
-isKeyUnlockedThin KeyMissing = False
-
-getKeyStatus :: Key -> Annex KeyStatus
-getKeyStatus key = catchDefaultIO KeyMissing $ do
-       afs <- not . null <$> Database.Keys.getAssociatedFiles key
-       obj <- calcRepo (gitAnnexLocation key)
-       multilink <- ((> 1) . linkCount <$> liftIO (R.getFileStatus obj))
-       return $ if multilink && afs
-               then KeyUnlockedThin
-               else KeyPresent
-
-getKeyFileStatus :: Key -> FilePath -> Annex KeyStatus
-getKeyFileStatus key file = do
-       s <- getKeyStatus key
-       case s of
-               KeyUnlockedThin -> catchDefaultIO KeyUnlockedThin $
-                       ifM (isJust <$> isAnnexLink (toRawFilePath file))
-                               ( return KeyLockedThin
-                               , return KeyUnlockedThin
-                               )
-               _ -> return s
-
index 1844f9a63b1ad87f7d887c929bd2be8d31b53122..0a4b3c77d0b78539951b88dfdd3f911a1e7b7ed3 100644 (file)
@@ -96,7 +96,7 @@ perform onlyremovesize o file oldkey oldbackend newbackend = go =<< genkey (fast
                | knowngoodcontent = finish (removesize newkey)
                | otherwise = stopUnless checkcontent $
                        finish (removesize newkey)
-       checkcontent = Command.Fsck.checkBackend oldbackend oldkey Command.Fsck.KeyPresent afile
+       checkcontent = Command.Fsck.checkBackend oldbackend oldkey KeyPresent afile
        finish newkey = ifM (Command.ReKey.linkKey file oldkey newkey)
                ( do
                        _ <- copyMetaData oldkey newkey