fix build warning

A recent change made plumbing the backend through fsck unncessary.

Left fsck checking backend and skipping operating on key when it could
not find one, although I'm not sure if that's necessary to support eg,
keys with unknown backend.
This commit is contained in:
Joey Hess 2024-03-09 13:50:30 -04:00
parent 7cef5e8f35
commit dd4c4bcd7a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 19 additions and 19 deletions

View file

@ -128,7 +128,7 @@ start from inc si file key = Backend.getBackend (fromRawFilePath file) key >>= \
(numcopies, _mincopies) <- getFileNumMinCopies file (numcopies, _mincopies) <- getFileNumMinCopies file
case from of case from of
Nothing -> go $ perform key file backend numcopies Nothing -> go $ perform key file backend numcopies
Just r -> go $ performRemote key afile backend numcopies r Just r -> go $ performRemote key afile numcopies r
where where
go = runFsck inc si (mkActionItem (key, afile)) key go = runFsck inc si (mkActionItem (key, afile)) key
afile = AssociatedFile (Just file) afile = AssociatedFile (Just file)
@ -145,7 +145,7 @@ perform key file backend numcopies = do
, verifyAssociatedFiles key keystatus file , verifyAssociatedFiles key keystatus file
, verifyWorkTree key file , verifyWorkTree key file
, checkKeySize key keystatus ai , checkKeySize key keystatus ai
, checkBackend backend key keystatus afile , checkBackend key keystatus afile
, checkKeyUpgrade backend key ai afile , checkKeyUpgrade backend key ai afile
, checkKeyNumCopies key afile numcopies , checkKeyNumCopies key afile numcopies
] ]
@ -155,8 +155,8 @@ perform key file backend numcopies = do
{- To fsck a remote, the content is retrieved to a tmp file, {- To fsck a remote, the content is retrieved to a tmp file,
- and checked locally. -} - and checked locally. -}
performRemote :: Key -> AssociatedFile -> Backend -> NumCopies -> Remote -> Annex Bool performRemote :: Key -> AssociatedFile -> NumCopies -> Remote -> Annex Bool
performRemote key afile backend numcopies remote = performRemote key afile numcopies remote =
dispatch =<< Remote.hasKey remote key dispatch =<< Remote.hasKey remote key
where where
dispatch (Left err) = do dispatch (Left err) = do
@ -179,7 +179,7 @@ performRemote key afile backend numcopies remote =
, case fmap snd lv of , case fmap snd lv of
Just Verified -> return True Just Verified -> return True
_ -> withLocalCopy (fmap fst lv) $ _ -> withLocalCopy (fmap fst lv) $
checkBackendRemote backend key remote ai checkBackendRemote key remote ai
, checkKeyNumCopies key afile numcopies , checkKeyNumCopies key afile numcopies
] ]
ai = mkActionItem (key, afile) ai = mkActionItem (key, afile)
@ -218,16 +218,16 @@ startKey from inc (si, key, ai) numcopies =
Nothing -> stop Nothing -> stop
Just backend -> runFsck inc si ai key $ Just backend -> runFsck inc si ai key $
case from of case from of
Nothing -> performKey key backend numcopies Nothing -> performKey key numcopies
Just r -> performRemote key (AssociatedFile Nothing) backend numcopies r Just r -> performRemote key (AssociatedFile Nothing) numcopies r
performKey :: Key -> Backend -> NumCopies -> Annex Bool performKey :: Key -> NumCopies -> Annex Bool
performKey key backend numcopies = do performKey key numcopies = do
keystatus <- getKeyStatus key keystatus <- getKeyStatus key
check check
[ verifyLocationLog key keystatus (mkActionItem key) [ verifyLocationLog key keystatus (mkActionItem key)
, checkKeySize key keystatus (mkActionItem key) , checkKeySize key keystatus (mkActionItem key)
, checkBackend backend key keystatus (AssociatedFile Nothing) , checkBackend key keystatus (AssociatedFile Nothing)
, checkKeyNumCopies key (AssociatedFile Nothing) numcopies , checkKeyNumCopies key (AssociatedFile Nothing) numcopies
] ]
@ -501,14 +501,14 @@ checkKeyUpgrade _ _ _ (AssociatedFile Nothing) =
- Thus when the user modifies the file, the object will be modified and - Thus when the user modifies the file, the object will be modified and
- not pass the check, and we don't want to find an error in this case. - not pass the check, and we don't want to find an error in this case.
-} -}
checkBackend :: Backend -> Key -> KeyStatus -> AssociatedFile -> Annex Bool checkBackend :: Key -> KeyStatus -> AssociatedFile -> Annex Bool
checkBackend backend key keystatus afile = do checkBackend key keystatus afile = do
content <- calcRepo (gitAnnexLocation key) content <- calcRepo (gitAnnexLocation key)
ifM (pure (isKeyUnlockedThin keystatus) <&&> (not <$> isUnmodified key content)) ifM (pure (isKeyUnlockedThin keystatus) <&&> (not <$> isUnmodified key content))
( nocheck ( nocheck
, do , do
mic <- withTSDelta (liftIO . genInodeCache content) mic <- withTSDelta (liftIO . genInodeCache content)
ifM (checkBackendOr badContent backend key content ai) ifM (checkBackendOr badContent key content ai)
( do ( do
checkInodeCache key content mic ai checkInodeCache key content mic ai
return True return True
@ -520,12 +520,12 @@ checkBackend backend key keystatus afile = do
ai = mkActionItem (key, afile) ai = mkActionItem (key, afile)
checkBackendRemote :: Backend -> Key -> Remote -> ActionItem -> RawFilePath -> Annex Bool checkBackendRemote :: Key -> Remote -> ActionItem -> RawFilePath -> Annex Bool
checkBackendRemote backend key remote ai localcopy = checkBackendRemote key remote ai localcopy =
checkBackendOr (badContentRemote remote localcopy) backend key localcopy ai checkBackendOr (badContentRemote remote localcopy) key localcopy ai
checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> RawFilePath -> ActionItem -> Annex Bool checkBackendOr :: (Key -> Annex String) -> Key -> RawFilePath -> ActionItem -> Annex Bool
checkBackendOr bad backend key file ai = do checkBackendOr bad key file ai = do
ok <- verifyKeyContent' key file ok <- verifyKeyContent' key file
unless ok $ do unless ok $ do
msg <- bad key msg <- bad key

View file

@ -126,7 +126,7 @@ perform onlytweaksize o file oldkey oldkeyrec oldbackend newbackend = go =<< gen
| knowngoodcontent = finish =<< tweaksize newkey | knowngoodcontent = finish =<< tweaksize newkey
| otherwise = stopUnless checkcontent $ | otherwise = stopUnless checkcontent $
finish =<< tweaksize newkey finish =<< tweaksize newkey
checkcontent = Command.Fsck.checkBackend oldbackend oldkey KeyPresent afile checkcontent = Command.Fsck.checkBackend oldkey KeyPresent afile
finish newkey = ifM (Command.ReKey.linkKey file oldkey newkey) finish newkey = ifM (Command.ReKey.linkKey file oldkey newkey)
( do ( do
_ <- copyMetaData oldkey newkey _ <- copyMetaData oldkey newkey