diff --git a/Backend/Hash.hs b/Backend/Hash.hs index a100de9896..d4d84db0d4 100644 --- a/Backend/Hash.hs +++ b/Backend/Hash.hs @@ -26,7 +26,6 @@ import Types.Backend import Types.KeySource import Utility.Hash import Utility.Metered -import qualified Utility.RawFilePath as R import qualified Data.ByteString as S import qualified Data.ByteString.Short as S (toShort, fromShort) @@ -129,14 +128,9 @@ keyValueE hash source meterupdate = checkKeyChecksum :: (Key -> String -> Bool) -> Hash -> Key -> RawFilePath -> Annex Bool checkKeyChecksum issame hash key file = catchIOErrorType HardwareFault hwfault $ do - fast <- Annex.getRead Annex.fast - exists <- liftIO $ R.doesPathExist file - case (exists, fast) of - (True, False) -> do - showAction (UnquotedString descChecksum) - issame key - <$> hashFile hash file nullMeterUpdate - _ -> return True + showAction (UnquotedString descChecksum) + issame key + <$> hashFile hash file nullMeterUpdate where hwfault e = do warning $ UnquotedString $ "hardware fault: " ++ show e diff --git a/CHANGELOG b/CHANGELOG index 224c735dbf..7602a13b8a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,10 @@ git-annex (10.20240431) UNRELEASED; urgency=medium * git-remote-annex: New program which allows pushing a git repo to a git-annex special remote, and cloning from a special remote. (Based on Michael Hanke's git-remote-datalad-annex.) + * fsck: Fix recent reversion that made it say it was checksumming files + whose content is not present. + * Avoid the --fast option preventing checksumming in some cases it + was not supposed to. * Typo fixes. Thanks, Yaroslav Halchenko diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 344d21ac81..f08d09f89f 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -504,16 +504,19 @@ checkKeyUpgrade _ _ _ (AssociatedFile Nothing) = checkBackend :: Key -> KeyStatus -> AssociatedFile -> Annex Bool checkBackend key keystatus afile = do content <- calcRepo (gitAnnexLocation key) - ifM (pure (isKeyUnlockedThin keystatus) <&&> (not <$> isUnmodified key content)) - ( nocheck - , do - mic <- withTSDelta (liftIO . genInodeCache content) - ifM (checkBackendOr badContent key content ai) - ( do - checkInodeCache key content mic ai - return True - , return False - ) + ifM (liftIO $ R.doesPathExist content) + ( ifM (pure (isKeyUnlockedThin keystatus) <&&> (not <$> isUnmodified key content)) + ( nocheck + , do + mic <- withTSDelta (liftIO . genInodeCache content) + ifM (checkBackendOr badContent key content ai) + ( do + checkInodeCache key content mic ai + return True + , return False + ) + ) + , nocheck ) where nocheck = return True @@ -525,14 +528,18 @@ checkBackendRemote key remote ai localcopy = checkBackendOr (badContentRemote remote localcopy) key localcopy ai checkBackendOr :: (Key -> Annex String) -> Key -> RawFilePath -> ActionItem -> Annex Bool -checkBackendOr bad key file ai = do - ok <- verifyKeyContent' key file - unless ok $ do - msg <- bad key - warning $ actionItemDesc ai - <> ": Bad file content; " - <> UnquotedString msg - return ok +checkBackendOr bad key file ai = + ifM (Annex.getRead Annex.fast) + ( return True + , do + ok <- verifyKeyContent' key file + unless ok $ do + msg <- bad key + warning $ actionItemDesc ai + <> ": Bad file content; " + <> UnquotedString msg + return ok + ) {- Check, if there are InodeCaches recorded for a key, that one of them - matches the object file. There are situations where the InodeCache diff --git a/doc/bugs/adjust_or_sync_in_unlock-present_repo_removes_+x_permission.mdwn b/doc/bugs/adjust_or_sync_in_unlock-present_repo_removes_+x_permission.mdwn new file mode 100644 index 0000000000..5dd73cc7a0 --- /dev/null +++ b/doc/bugs/adjust_or_sync_in_unlock-present_repo_removes_+x_permission.mdwn @@ -0,0 +1,34 @@ +It seems that performing `git annex adjust --unlock-present` or `sync` +will remove the +x permission from files. + +Steps to reproduce: + +$ mkdir /tmp/ga; cd /tmp/ga; git init ; git annex init +$ touch a.txt s.sh +$ chmod +x s.sh +$ git annex add . && git annex sync +$ stat -Lc%A s.sh +-r-xr-xr-x +$ git annex adjust --unlock-present +$ stat -c%A s.sh +-rw-r--r-- + +The permission is removed also after a sync, but only in case other +files have been changed (and adjust called behind the scenes): + +$ chmod +x s.sh +$ git annex sync +$ stat -c%A s.sh +-rwxr-xr-x +$ git annex drop --force a.txt +$ stat -c%A s.sh +-rwxr-xr-x +$ git annex sync +$ stat -c%A s.sh +-rw-r--r-- + +I'm using git-annex version: 10.20240430-g5b36e6b4 with +annex.alwayscommit = false. + +PS: git-annex is so solid that this is the first data-related issue I've +ever seen. Kudos!