migrate: support adding size back to URL keys
migrate: Support adding size to URL keys that were added with --relaxed, by running eg: git-annex migrate --backend=URL foo Since url keys cannot be generated, that used to fail. Make it notice that the backend is not changed, and just get the size of the content. Sponsored-by: Brock Spratlen on Patreon
This commit is contained in:
parent
cb9bb2027c
commit
86dbe9a825
5 changed files with 59 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex file content managing
|
||||
-
|
||||
- Copyright 2010-2022 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -66,6 +66,7 @@ module Annex.Content (
|
|||
getKeyStatus,
|
||||
getKeyFileStatus,
|
||||
cleanObjectDirs,
|
||||
contentSize,
|
||||
) where
|
||||
|
||||
import System.IO.Unsafe (unsafeInterleaveIO)
|
||||
|
@ -916,3 +917,25 @@ getKeyFileStatus key file = do
|
|||
)
|
||||
_ -> return s
|
||||
|
||||
{- Gets the size of the content of a key when it is present.
|
||||
- Useful when the key does not have keySize set.
|
||||
-
|
||||
- When the object file appears possibly modified with annex.thin set, does
|
||||
- not do an expensive verification that the content is good, just returns
|
||||
- Nothing.
|
||||
-}
|
||||
contentSize :: Key -> Annex (Maybe FileSize)
|
||||
contentSize key = catchDefaultIO Nothing $
|
||||
withObjectLoc key $ \loc ->
|
||||
withTSDelta (liftIO . genInodeCache loc) >>= \case
|
||||
Just ic -> ifM (unmodified ic)
|
||||
( return (Just (inodeCacheFileSize ic))
|
||||
, return Nothing
|
||||
)
|
||||
Nothing -> return Nothing
|
||||
where
|
||||
unmodified ic =
|
||||
ifM (annexThin <$> Annex.getGitConfig)
|
||||
( isUnmodifiedCheap' key ic
|
||||
, return True
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue