add per-remote-type info
Now `git annex info $remote` shows info specific to the type of the remote, for example, it shows the rsync url. Remote types that support encryption or chunking also include that in their info. This commit was sponsored by Ævar Arnfjörð Bjarmason.
This commit is contained in:
parent
aafaa363e3
commit
a0297915c1
20 changed files with 82 additions and 29 deletions
|
@ -8,6 +8,7 @@
|
|||
module Remote.Helper.Chunked (
|
||||
ChunkSize,
|
||||
ChunkConfig(..),
|
||||
describeChunkConfig,
|
||||
getChunkConfig,
|
||||
storeChunks,
|
||||
removeChunks,
|
||||
|
@ -34,6 +35,14 @@ data ChunkConfig
|
|||
| LegacyChunks ChunkSize
|
||||
deriving (Show)
|
||||
|
||||
describeChunkConfig :: ChunkConfig -> String
|
||||
describeChunkConfig NoChunks = "none"
|
||||
describeChunkConfig (UnpaddedChunks sz) = describeChunkSize sz ++ "chunks"
|
||||
describeChunkConfig (LegacyChunks sz) = describeChunkSize sz ++ " chunks (old style)"
|
||||
|
||||
describeChunkSize :: ChunkSize -> String
|
||||
describeChunkSize sz = roughSize storageUnits False (fromIntegral sz)
|
||||
|
||||
noChunks :: ChunkConfig -> Bool
|
||||
noChunks NoChunks = True
|
||||
noChunks _ = False
|
||||
|
|
|
@ -16,6 +16,7 @@ module Remote.Helper.Encryptable (
|
|||
cipherKey,
|
||||
storeCipher,
|
||||
extractCipher,
|
||||
describeEncryption,
|
||||
) where
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
@ -157,3 +158,10 @@ extractCipher c = case (M.lookup "cipher" c,
|
|||
_ -> Nothing
|
||||
where
|
||||
readkeys = KeyIds . split ","
|
||||
|
||||
describeEncryption :: RemoteConfig -> String
|
||||
describeEncryption c = case extractCipher c of
|
||||
Nothing -> "not encrypted"
|
||||
(Just (SharedCipher _)) -> "encrypted (encryption key stored in git repository)"
|
||||
(Just (EncryptedCipher _ _ (KeyIds { keyIds = ks }))) ->
|
||||
"encrypted (to gpg keys: " ++ unwords ks ++ ")"
|
||||
|
|
|
@ -30,3 +30,8 @@ guardUsable :: Git.Repo -> Annex a -> Annex a -> Annex a
|
|||
guardUsable r fallback a
|
||||
| Git.repoIsLocalUnknown r = fallback
|
||||
| otherwise = a
|
||||
|
||||
gitRepoInfo :: Git.Repo -> [(String, String)]
|
||||
gitRepoInfo r =
|
||||
[ ("repository location", Git.repoLocation r)
|
||||
]
|
||||
|
|
|
@ -168,6 +168,12 @@ specialRemote' cfg c preparestorer prepareretriever prepareremover preparecheckp
|
|||
(cost baser)
|
||||
(const $ cost baser + encryptedRemoteCostAdj)
|
||||
(extractCipher c)
|
||||
, getInfo = do
|
||||
l <- getInfo baser
|
||||
return $ l ++
|
||||
[ ("encryption", describeEncryption c)
|
||||
, ("chunking", describeChunkConfig (chunkConfig cfg))
|
||||
]
|
||||
}
|
||||
cip = cipherKey c
|
||||
gpgopts = getGpgEncParams encr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue