From 43201c32868c12461b46dd7e503c653608a40198 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Oct 2014 14:36:09 -0400 Subject: add per-remote-type info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- Remote/Helper/Chunked.hs | 9 +++++++++ Remote/Helper/Encryptable.hs | 8 ++++++++ Remote/Helper/Git.hs | 5 +++++ Remote/Helper/Special.hs | 6 ++++++ 4 files changed, 28 insertions(+) (limited to 'Remote/Helper') diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs index eb5dbc793..806fab542 100644 --- a/Remote/Helper/Chunked.hs +++ b/Remote/Helper/Chunked.hs @@ -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 diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs index 9a8e9ba5b..5e342803d 100644 --- a/Remote/Helper/Encryptable.hs +++ b/Remote/Helper/Encryptable.hs @@ -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 ++ ")" diff --git a/Remote/Helper/Git.hs b/Remote/Helper/Git.hs index b405fd358..156d7ac28 100644 --- a/Remote/Helper/Git.hs +++ b/Remote/Helper/Git.hs @@ -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) + ] diff --git a/Remote/Helper/Special.hs b/Remote/Helper/Special.hs index 4738180a8..181d7548f 100644 --- a/Remote/Helper/Special.hs +++ b/Remote/Helper/Special.hs @@ -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 -- cgit v1.2.3