Verification(..),
unVerified,
withTmpWorkDir,
+ KeyStatus(..),
+ isKeyUnlockedThin,
+ getKeyStatus,
+ getKeyFileStatus,
) where
import System.IO.Unsafe (unsafeInterleaveIO)
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
+
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
-
| 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