Merge branch 'v7'

This commit is contained in:
Joey Hess 2020-02-26 18:15:18 -04:00
commit 81e3faf810
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
30 changed files with 207 additions and 158 deletions

View file

@ -11,7 +11,8 @@
module Annex.SpecialRemote.Config where module Annex.SpecialRemote.Config where
import Common import Common
import Types.Remote (RemoteConfigField, RemoteConfig) import Types.Remote (RemoteConfigField, RemoteConfig, configParser)
import Types
import Types.UUID import Types.UUID
import Types.ProposedAccepted import Types.ProposedAccepted
import Types.RemoteConfig import Types.RemoteConfig
@ -106,6 +107,10 @@ commonFieldParsers =
(FieldDesc "type of special remote") (FieldDesc "type of special remote")
, trueFalseParser autoEnableField False , trueFalseParser autoEnableField False
(FieldDesc "automatically enable special remote") (FieldDesc "automatically enable special remote")
, yesNoParser exportTreeField False
(FieldDesc "export trees of files to this remote")
, yesNoParser importTreeField False
(FieldDesc "import trees of files from this remote")
, optionalStringParser preferreddirField , optionalStringParser preferreddirField
(FieldDesc "directory whose content is preferred") (FieldDesc "directory whose content is preferred")
] ]
@ -162,7 +167,7 @@ findByRemoteConfig matching = map sameasuuid . filter (matching . snd) . M.toLis
{- Extracts a value from ParsedRemoteConfig. -} {- Extracts a value from ParsedRemoteConfig. -}
getRemoteConfigValue :: HasCallStack => Typeable v => RemoteConfigField -> ParsedRemoteConfig -> Maybe v getRemoteConfigValue :: HasCallStack => Typeable v => RemoteConfigField -> ParsedRemoteConfig -> Maybe v
getRemoteConfigValue f m = case M.lookup f m of getRemoteConfigValue f (ParsedRemoteConfig m _) = case M.lookup f m of
Just (RemoteConfigValue v) -> case cast v of Just (RemoteConfigValue v) -> case cast v of
Just v' -> Just v' Just v' -> Just v'
Nothing -> error $ unwords Nothing -> error $ unwords
@ -176,13 +181,20 @@ getRemoteConfigValue f m = case M.lookup f m of
{- Gets all fields that remoteConfigRestPassthrough matched. -} {- Gets all fields that remoteConfigRestPassthrough matched. -}
getRemoteConfigPassedThrough :: ParsedRemoteConfig -> M.Map RemoteConfigField String getRemoteConfigPassedThrough :: ParsedRemoteConfig -> M.Map RemoteConfigField String
getRemoteConfigPassedThrough = M.mapMaybe $ \(RemoteConfigValue v) -> getRemoteConfigPassedThrough (ParsedRemoteConfig m _) =
case cast v of flip M.mapMaybe m $ \(RemoteConfigValue v) ->
Just (PassedThrough s) -> Just s case cast v of
Nothing -> Nothing Just (PassedThrough s) -> Just s
Nothing -> Nothing
newtype PassedThrough = PassedThrough String newtype PassedThrough = PassedThrough String
parsedRemoteConfig :: RemoteType -> RemoteConfig -> Annex ParsedRemoteConfig
parsedRemoteConfig t c = either (const emptycfg) id . parseRemoteConfig c
<$> configParser t c
where
emptycfg = ParsedRemoteConfig mempty c
parseRemoteConfig :: RemoteConfig -> RemoteConfigParser -> Either String ParsedRemoteConfig parseRemoteConfig :: RemoteConfig -> RemoteConfigParser -> Either String ParsedRemoteConfig
parseRemoteConfig c rpc = parseRemoteConfig c rpc =
go [] c (remoteConfigFieldParsers rpc ++ commonFieldParsers) go [] c (remoteConfigFieldParsers rpc ++ commonFieldParsers)
@ -195,8 +207,10 @@ parseRemoteConfig c rpc =
in if not (null leftovers') in if not (null leftovers')
then Left $ "Unexpected parameters: " ++ then Left $ "Unexpected parameters: " ++
unwords (map (fromProposedAccepted . fst) leftovers') unwords (map (fromProposedAccepted . fst) leftovers')
else Right $ M.fromList $ else
l ++ map (uncurry passthrough) passover let m = M.fromList $
l ++ map (uncurry passthrough) passover
in Right (ParsedRemoteConfig m c)
go l c' (p:rest) = do go l c' (p:rest) = do
let f = parserForField p let f = parserForField p
(valueParser p) (M.lookup f c) c >>= \case (valueParser p) (M.lookup f c) c >>= \case

View file

@ -170,8 +170,7 @@ getEnableS3R uuid = do
m <- liftAnnex readRemoteLog m <- liftAnnex readRemoteLog
isia <- case M.lookup uuid m of isia <- case M.lookup uuid m of
Just c -> liftAnnex $ do Just c -> liftAnnex $ do
pc <- either mempty id . parseRemoteConfig c pc <- parsedRemoteConfig S3.remote c
<$> Remote.configParser S3.remote c
return $ S3.configIA pc return $ S3.configIA pc
Nothing -> return False Nothing -> return False
if isia if isia

View file

@ -256,8 +256,7 @@ getRepoInfo :: Maybe Remote.Remote -> Remote.RemoteConfig -> Widget
getRepoInfo (Just r) c = case fromProposedAccepted <$> M.lookup typeField c of getRepoInfo (Just r) c = case fromProposedAccepted <$> M.lookup typeField c of
Just "S3" -> do Just "S3" -> do
#ifdef WITH_S3 #ifdef WITH_S3
pc <- liftAnnex $ either mempty id . parseRemoteConfig c pc <- liftAnnex $ parsedRemoteConfig S3.remote c
<$> Remote.configParser S3.remote c
if S3.configIA pc if S3.configIA pc
then IA.getRepoInfo c then IA.getRepoInfo c
else AWS.getRepoInfo c else AWS.getRepoInfo c
@ -283,7 +282,8 @@ getRepoEncryption (Just _) (Just c) = case extractCipher pc of
(Just (EncryptedCipher _ _ ks)) -> desckeys ks (Just (EncryptedCipher _ _ ks)) -> desckeys ks
(Just (SharedPubKeyCipher _ ks)) -> desckeys ks (Just (SharedPubKeyCipher _ ks)) -> desckeys ks
where where
pc = either mempty id $ parseEncryptionConfig c pc = either (const (Remote.ParsedRemoteConfig mempty mempty)) id $
parseEncryptionConfig c
desckeys (KeyIds { keyIds = ks }) = do desckeys (KeyIds { keyIds = ks }) = do
cmd <- liftAnnex $ gpgCmd <$> Annex.getGitConfig cmd <- liftAnnex $ gpgCmd <$> Annex.getGitConfig
knownkeys <- liftIO (secretKeys cmd) knownkeys <- liftIO (secretKeys cmd)

View file

@ -15,7 +15,7 @@ import Creds
import qualified Remote.WebDAV as WebDAV import qualified Remote.WebDAV as WebDAV
import Assistant.WebApp.MakeRemote import Assistant.WebApp.MakeRemote
import qualified Remote import qualified Remote
import Types.Remote (RemoteConfig, configParser) import Types.Remote (RemoteConfig)
import Types.StandardGroups import Types.StandardGroups
import Logs.Remote import Logs.Remote
import Git.Types (RemoteName) import Git.Types (RemoteName)
@ -62,8 +62,7 @@ postEnableWebDAVR uuid = do
let url = fromProposedAccepted $ fromJust $ M.lookup (Accepted "url") c let url = fromProposedAccepted $ fromJust $ M.lookup (Accepted "url") c
mcreds <- liftAnnex $ do mcreds <- liftAnnex $ do
dummycfg <- liftIO dummyRemoteGitConfig dummycfg <- liftIO dummyRemoteGitConfig
pc <- either mempty id . parseRemoteConfig c pc <- parsedRemoteConfig WebDAV.remote c
<$> configParser WebDAV.remote c
getRemoteCredPairFor "webdav" pc dummycfg (WebDAV.davCreds uuid) getRemoteCredPairFor "webdav" pc dummycfg (WebDAV.davCreds uuid)
case mcreds of case mcreds of
Just creds -> webDAVConfigurator $ liftH $ Just creds -> webDAVConfigurator $ liftH $

View file

@ -1,4 +1,4 @@
git-annex (8.20200221) UNRELEASED; urgency=medium git-annex (8.20200226) UNRELEASED; urgency=medium
* New v8 repository version. * New v8 repository version.
* v7 upgrades automatically to v8. The upgrade deletes old sqlite * v7 upgrades automatically to v8. The upgrade deletes old sqlite
@ -19,8 +19,6 @@ git-annex (8.20200221) UNRELEASED; urgency=medium
that no longer adds them to the annex, but to git. This behavior that no longer adds them to the annex, but to git. This behavior
can be configured with annex.dotfiles. can be configured with annex.dotfiles.
* add: Removed the --include-dotfiles option. * add: Removed the --include-dotfiles option.
* Bugfix: export --tracking (a deprecated option) set
annex-annex-tracking-branch, instead of annex-tracking-branch.
* initremote, enableremote: Set remote.name.skipFetchAll when * initremote, enableremote: Set remote.name.skipFetchAll when
the remote cannot be fetched from by git, so git fetch --all the remote cannot be fetched from by git, so git fetch --all
will not try to use it. will not try to use it.
@ -34,12 +32,24 @@ git-annex (8.20200221) UNRELEASED; urgency=medium
* Auto upgrades from older repo versions, like v5, now jump right to v8. * Auto upgrades from older repo versions, like v5, now jump right to v8.
* Extended annex.security.allowed-ip-addresses to let specific ports * Extended annex.security.allowed-ip-addresses to let specific ports
of an IP address to be used, while denying use of other ports. of an IP address to be used, while denying use of other ports.
* Bugfix to getting content from an export remote with -J, when the
export database was not yet populated. -- Joey Hess <id@joeyh.name> Wed, 26 Feb 2020 17:18:16 -0400
git-annex (7.20200226) upstream; urgency=high
* Fix serious regression in gcrypt and encrypted git-lfs remotes.
Since version 7.20200202.7, git-annex incorrectly stored content
on those remotes without encrypting it.
If your remotes are affected, you will want to make sure to delete
any content that git-annex has stored on them that is not encrypted!
* info: Fix display of the encryption value. * info: Fix display of the encryption value.
(Some debugging junk had crept in.) (Some debugging junk had crept in.)
* Bugfix to getting content from an export remote with -J, when the
export database was not yet populated.
* Bugfix: export --tracking (a deprecated option) set
annex-annex-tracking-branch, instead of annex-tracking-branch.
-- Joey Hess <id@joeyh.name> Wed, 19 Feb 2020 12:48:58 -0400 -- Joey Hess <id@joeyh.name> Wed, 26 Feb 2020 17:18:16 -0400
git-annex (7.20200219) upstream; urgency=medium git-annex (7.20200219) upstream; urgency=medium

View file

@ -24,8 +24,8 @@ import Utility.DataUnits
import Utility.CopyFile import Utility.CopyFile
import Types.Messages import Types.Messages
import Types.Export import Types.Export
import Types.Crypto
import Types.RemoteConfig import Types.RemoteConfig
import Types.ProposedAccepted
import Annex.SpecialRemote.Config (exportTreeField) import Annex.SpecialRemote.Config (exportTreeField)
import Remote.Helper.ExportImport import Remote.Helper.ExportImport
import Remote.Helper.Chunked import Remote.Helper.Chunked
@ -122,18 +122,18 @@ perform rs unavailrs exportr ks = do
] ]
adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote) adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote)
adjustChunkSize r chunksize = adjustRemoteConfig r adjustChunkSize r chunksize = adjustRemoteConfig r $
(M.insert chunkField (RemoteConfigValue (show chunksize))) M.insert chunkField (Proposed (show chunksize))
-- Variants of a remote with no encryption, and with simple shared -- Variants of a remote with no encryption, and with simple shared
-- encryption. Gpg key based encryption is not tested. -- encryption. Gpg key based encryption is not tested.
encryptionVariants :: Remote -> Annex [Remote] encryptionVariants :: Remote -> Annex [Remote]
encryptionVariants r = do encryptionVariants r = do
noenc <- adjustRemoteConfig r $ noenc <- adjustRemoteConfig r $
M.insert encryptionField (RemoteConfigValue NoneEncryption) M.insert encryptionField (Proposed "none")
sharedenc <- adjustRemoteConfig r $ sharedenc <- adjustRemoteConfig r $
M.insert encryptionField (RemoteConfigValue SharedEncryption) . M.insert encryptionField (Proposed "shared") .
M.insert highRandomQualityField (RemoteConfigValue False) M.insert highRandomQualityField (Proposed "false")
return $ catMaybes [noenc, sharedenc] return $ catMaybes [noenc, sharedenc]
-- Variant of a remote with exporttree disabled. -- Variant of a remote with exporttree disabled.
@ -145,19 +145,20 @@ disableExportTree r = maybe (error "failed disabling exportree") return
exportTreeVariant :: Remote -> Annex (Maybe Remote) exportTreeVariant :: Remote -> Annex (Maybe Remote)
exportTreeVariant r = ifM (Remote.isExportSupported r) exportTreeVariant r = ifM (Remote.isExportSupported r)
( adjustRemoteConfig r $ ( adjustRemoteConfig r $
M.insert encryptionField (RemoteConfigValue NoneEncryption) . M.insert encryptionField (Proposed "none") .
M.insert exportTreeField (RemoteConfigValue True) M.insert exportTreeField (Proposed "yes")
, return Nothing , return Nothing
) )
-- Regenerate a remote with a modified config. -- Regenerate a remote with a modified config.
adjustRemoteConfig :: Remote -> (Remote.ParsedRemoteConfig -> Remote.ParsedRemoteConfig) -> Annex (Maybe Remote) adjustRemoteConfig :: Remote -> (Remote.RemoteConfig -> Remote.RemoteConfig) -> Annex (Maybe Remote)
adjustRemoteConfig r adjustconfig = do adjustRemoteConfig r adjustconfig = do
repo <- Remote.getRepo r repo <- Remote.getRepo r
let ParsedRemoteConfig _ origc = Remote.config r
Remote.generate (Remote.remotetype r) Remote.generate (Remote.remotetype r)
repo repo
(Remote.uuid r) (Remote.uuid r)
(adjustconfig (Remote.config r)) (adjustconfig origc)
(Remote.gitconfig r) (Remote.gitconfig r)
(Remote.remoteStateHandle r) (Remote.remoteStateHandle r)

View file

@ -57,8 +57,9 @@ data CredPairStorage = CredPairStorage
- cipher. The EncryptionIsSetup is witness to that being the case. - cipher. The EncryptionIsSetup is witness to that being the case.
-} -}
setRemoteCredPair :: EncryptionIsSetup -> RemoteConfig -> RemoteGitConfig -> CredPairStorage -> Maybe CredPair -> Annex RemoteConfig setRemoteCredPair :: EncryptionIsSetup -> RemoteConfig -> RemoteGitConfig -> CredPairStorage -> Maybe CredPair -> Annex RemoteConfig
setRemoteCredPair = setRemoteCredPair' id setRemoteCredPair = setRemoteCredPair' id go
(either (const mempty) id . parseEncryptionConfig) where
go c = either (const (ParsedRemoteConfig mempty c)) id (parseEncryptionConfig c)
setRemoteCredPair' setRemoteCredPair'
:: (ProposedAccepted String -> a) :: (ProposedAccepted String -> a)
@ -203,18 +204,18 @@ removeCreds file = do
liftIO $ nukeFile f liftIO $ nukeFile f
includeCredsInfo :: ParsedRemoteConfig -> CredPairStorage -> [(String, String)] -> Annex [(String, String)] includeCredsInfo :: ParsedRemoteConfig -> CredPairStorage -> [(String, String)] -> Annex [(String, String)]
includeCredsInfo c storage info = do includeCredsInfo pc@(ParsedRemoteConfig cm _) storage info = do
v <- liftIO $ getEnvCredPair storage v <- liftIO $ getEnvCredPair storage
case v of case v of
Just _ -> do Just _ -> do
let (uenv, penv) = credPairEnvironment storage let (uenv, penv) = credPairEnvironment storage
ret $ "from environment variables (" ++ unwords [uenv, penv] ++ ")" ret $ "from environment variables (" ++ unwords [uenv, penv] ++ ")"
Nothing -> case (`M.lookup` c) (credPairRemoteField storage) of Nothing -> case (`M.lookup` cm) (credPairRemoteField storage) of
Nothing -> ifM (existsCacheCredPair storage) Nothing -> ifM (existsCacheCredPair storage)
( ret "stored locally" ( ret "stored locally"
, ret "not available" , ret "not available"
) )
Just _ -> case extractCipher c of Just _ -> case extractCipher pc of
Just (EncryptedCipher {}) -> ret "embedded in git repository (gpg encrypted)" Just (EncryptedCipher {}) -> ret "embedded in git repository (gpg encrypted)"
_ -> ret "embedded in git repository (not encrypted)" _ -> ret "embedded in git repository (not encrypted)"
where where

19
NEWS
View file

@ -1,4 +1,4 @@
git-annex (8.20191107) upstream; urgency=medium git-annex (8.20200226) upstream; urgency=medium
This version of git-annex uses repository version 8 for all repositories. This version of git-annex uses repository version 8 for all repositories.
@ -20,7 +20,22 @@ git-annex (8.20191107) upstream; urgency=medium
and added dotfiles that were explicitly listed to the annex, it now adds and added dotfiles that were explicitly listed to the annex, it now adds
dotfiles to git by default, unless annex.dotfiles is set to true. dotfiles to git by default, unless annex.dotfiles is set to true.
-- Joey Hess <id@joeyh.name> Thu, 07 Nov 2019 13:21:11 -0400 -- Joey Hess <id@joeyh.name> Wed, 26 Feb 2020 17:18:16 -0400
git-annex (7.20200226) upstream; urgency=high
There was a serious regression in gcrypt and encrypted git-lfs remotes.
Since version 7.20200202.7, git-annex incorrectly stored content
on those remotes without encrypting it.
If your remotes are affected, you will want to make sure to delete
any content that git-annex has stored on them that is not encrypted!
One way to do so is, before upgrading to this version,
run git-annex move --from the affected remotes. It will move
only the content that was not encrypted.
-- Joey Hess <id@joeyh.name> Wed, 26 Feb 2020 17:18:16 -0400
git-annex (7.20191024) upstream; urgency=medium git-annex (7.20191024) upstream; urgency=medium

View file

@ -54,8 +54,9 @@ androiddirectoryField = Accepted "androiddirectory"
androidserialField :: RemoteConfigField androidserialField :: RemoteConfigField
androidserialField = Accepted "androidserial" androidserialField = Accepted "androidserial"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
let this = Remote let this = Remote
{ uuid = u { uuid = u
-- adb operates over USB or wifi, so is not as cheap -- adb operates over USB or wifi, so is not as cheap

View file

@ -28,6 +28,7 @@ import Annex.Tmp
import Annex.UUID import Annex.UUID
import qualified Annex.Url as Url import qualified Annex.Url as Url
import Remote.Helper.ExportImport import Remote.Helper.ExportImport
import Annex.SpecialRemote.Config
import Network.URI import Network.URI
@ -53,9 +54,10 @@ list _autoinit = do
r <- liftIO $ Git.Construct.remoteNamed "bittorrent" (pure Git.Construct.fromUnknown) r <- liftIO $ Git.Construct.remoteNamed "bittorrent" (pure Git.Construct.fromUnknown)
return [r] return [r]
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r _ c gc rs = do gen r _ rc gc rs = do
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
c <- parsedRemoteConfig remote rc
return $ Just Remote return $ Just Remote
{ uuid = bitTorrentUUID { uuid = bitTorrentUUID
, cost = cst , cost = cst

View file

@ -55,8 +55,9 @@ remote = specialRemoteType $ RemoteType
buprepoField :: RemoteConfigField buprepoField :: RemoteConfigField
buprepoField = Accepted "buprepo" buprepoField = Accepted "buprepo"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
bupr <- liftIO $ bup2GitRemote buprepo bupr <- liftIO $ bup2GitRemote buprepo
cst <- remoteCost gc $ cst <- remoteCost gc $
if bupLocal buprepo if bupLocal buprepo
@ -99,6 +100,10 @@ gen r u c gc rs = do
, checkUrl = Nothing , checkUrl = Nothing
, remoteStateHandle = rs , remoteStateHandle = rs
} }
let specialcfg = (specialRemoteCfg c)
-- chunking would not improve bup
{ chunkConfig = NoChunks
}
return $ Just $ specialRemote' specialcfg c return $ Just $ specialRemote' specialcfg c
(simplyPrepare $ store this buprepo) (simplyPrepare $ store this buprepo)
(simplyPrepare $ retrieve buprepo) (simplyPrepare $ retrieve buprepo)
@ -107,10 +112,6 @@ gen r u c gc rs = do
this this
where where
buprepo = fromMaybe (giveup "missing buprepo") $ remoteAnnexBupRepo gc buprepo = fromMaybe (giveup "missing buprepo") $ remoteAnnexBupRepo gc
specialcfg = (specialRemoteCfg c)
-- chunking would not improve bup
{ chunkConfig = NoChunks
}
bupSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) bupSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
bupSetup _ mu _ c gc = do bupSetup _ mu _ c gc = do

View file

@ -48,20 +48,25 @@ remote = specialRemoteType $ RemoteType
ddarrepoField :: RemoteConfigField ddarrepoField :: RemoteConfigField
ddarrepoField = Accepted "ddarrepo" ddarrepoField = Accepted "ddarrepo"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc $ cst <- remoteCost gc $
if ddarLocal ddarrepo if ddarLocal ddarrepo
then nearlyCheapRemoteCost then nearlyCheapRemoteCost
else expensiveRemoteCost else expensiveRemoteCost
let specialcfg = (specialRemoteCfg c)
-- chunking would not improve ddar
{ chunkConfig = NoChunks
}
return $ Just $ specialRemote' specialcfg c return $ Just $ specialRemote' specialcfg c
(simplyPrepare $ store ddarrepo) (simplyPrepare $ store ddarrepo)
(simplyPrepare $ retrieve ddarrepo) (simplyPrepare $ retrieve ddarrepo)
(simplyPrepare $ remove ddarrepo) (simplyPrepare $ remove ddarrepo)
(simplyPrepare $ checkKey ddarrepo) (simplyPrepare $ checkKey ddarrepo)
(this cst) (this c cst)
where where
this cst = Remote this c cst = Remote
{ uuid = u { uuid = u
, cost = cst , cost = cst
, name = Git.repoDescribe r , name = Git.repoDescribe r
@ -97,10 +102,6 @@ gen r u c gc rs = do
, remoteStateHandle = rs , remoteStateHandle = rs
} }
ddarrepo = maybe (giveup "missing ddarrepo") (DdarRepo gc) (remoteAnnexDdarRepo gc) ddarrepo = maybe (giveup "missing ddarrepo") (DdarRepo gc) (remoteAnnexDdarRepo gc)
specialcfg = (specialRemoteCfg c)
-- chunking would not improve ddar
{ chunkConfig = NoChunks
}
ddarSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) ddarSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
ddarSetup _ mu _ c gc = do ddarSetup _ mu _ c gc = do

View file

@ -54,8 +54,9 @@ remote = specialRemoteType $ RemoteType
directoryField :: RemoteConfigField directoryField :: RemoteConfigField
directoryField = Accepted "directory" directoryField = Accepted "directory"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc cheapRemoteCost cst <- remoteCost gc cheapRemoteCost
let chunkconfig = getChunkConfig c let chunkconfig = getChunkConfig c
return $ Just $ specialRemote c return $ Just $ specialRemote c
@ -106,7 +107,7 @@ gen r u c gc rs = do
, appendonly = False , appendonly = False
, availability = LocallyAvailable , availability = LocallyAvailable
, remotetype = remote , remotetype = remote
, mkUnavailable = gen r u c , mkUnavailable = gen r u rc
(gc { remoteAnnexDirectory = Just "/dev/null" }) rs (gc { remoteAnnexDirectory = Just "/dev/null" }) rs
, getInfo = return [("directory", dir)] , getInfo = return [("directory", dir)]
, claimUrl = Nothing , claimUrl = Nothing

View file

@ -62,12 +62,13 @@ externaltypeField = Accepted "externaltype"
readonlyField :: RemoteConfigField readonlyField :: RemoteConfigField
readonlyField = Accepted "readonly" readonlyField = Accepted "readonly"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs gen r u rc gc rs
-- readonly mode only downloads urls; does not use external program -- readonly mode only downloads urls; does not use external program
| remoteAnnexReadOnly gc = do | remoteAnnexReadOnly gc = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
mk cst GloballyAvailable mk c cst GloballyAvailable
readonlyStorer readonlyStorer
retrieveUrl retrieveUrl
readonlyRemoveKey readonlyRemoveKey
@ -79,6 +80,7 @@ gen r u c gc rs
exportUnsupported exportUnsupported
exportUnsupported exportUnsupported
| otherwise = do | otherwise = do
c <- parsedRemoteConfig remote rc
external <- newExternal externaltype (Just u) c (Just gc) (Just rs) external <- newExternal externaltype (Just u) c (Just gc) (Just rs)
Annex.addCleanup (RemoteCleanup u) $ stopExternal external Annex.addCleanup (RemoteCleanup u) $ stopExternal external
cst <- getCost external r gc cst <- getCost external r gc
@ -101,7 +103,7 @@ gen r u c gc rs
let cheapexportsupported = if exportsupported let cheapexportsupported = if exportsupported
then exportIsSupported then exportIsSupported
else exportUnsupported else exportUnsupported
mk cst avail mk c cst avail
(storeKeyM external) (storeKeyM external)
(retrieveKeyFileM external) (retrieveKeyFileM external)
(removeKeyM external) (removeKeyM external)
@ -113,7 +115,7 @@ gen r u c gc rs
exportactions exportactions
cheapexportsupported cheapexportsupported
where where
mk cst avail tostore toretrieve toremove tocheckkey towhereis togetinfo toclaimurl tocheckurl exportactions cheapexportsupported = do mk c cst avail tostore toretrieve toremove tocheckkey towhereis togetinfo toclaimurl tocheckurl exportactions cheapexportsupported = do
let rmt = Remote let rmt = Remote
{ uuid = u { uuid = u
, cost = cst , cost = cst
@ -144,7 +146,7 @@ gen r u c gc rs
, availability = avail , availability = avail
, remotetype = remote , remotetype = remote
{ exportSupported = cheapexportsupported } { exportSupported = cheapexportsupported }
, mkUnavailable = gen r u c , mkUnavailable = gen r u rc
(gc { remoteAnnexExternalType = Just "!dne!" }) rs (gc { remoteAnnexExternalType = Just "!dne!" }) rs
, getInfo = togetinfo , getInfo = togetinfo
, claimUrl = toclaimurl , claimUrl = toclaimurl
@ -409,25 +411,28 @@ handleRequest' st external req mp responsehandler
send $ VALUE $ fromRawFilePath $ hashDirLower def k send $ VALUE $ fromRawFilePath $ hashDirLower def k
handleRemoteRequest (SETCONFIG setting value) = handleRemoteRequest (SETCONFIG setting value) =
liftIO $ atomically $ do liftIO $ atomically $ do
modifyTVar' (externalConfig st) $ modifyTVar' (externalConfig st) $ \(ParsedRemoteConfig m c) ->
M.insert (Accepted setting) $ let m' = M.insert
RemoteConfigValue (PassedThrough value) (Accepted setting)
(RemoteConfigValue (PassedThrough value))
m
in ParsedRemoteConfig m' c
modifyTVar' (externalConfigChanges st) $ \f -> modifyTVar' (externalConfigChanges st) $ \f ->
f . M.insert (Accepted setting) (Accepted value) f . M.insert (Accepted setting) (Accepted value)
handleRemoteRequest (GETCONFIG setting) = do handleRemoteRequest (GETCONFIG setting) = do
value <- fromMaybe "" value <- fromMaybe ""
. M.lookup (Accepted setting) . (M.lookup (Accepted setting))
. getRemoteConfigPassedThrough . getRemoteConfigPassedThrough
<$> liftIO (atomically $ readTVar $ externalConfig st) <$> liftIO (atomically $ readTVar $ externalConfig st)
send $ VALUE value send $ VALUE value
handleRemoteRequest (SETCREDS setting login password) = case (externalUUID external, externalGitConfig external) of handleRemoteRequest (SETCREDS setting login password) = case (externalUUID external, externalGitConfig external) of
(Just u, Just gc) -> do (Just u, Just gc) -> do
let v = externalConfig st let v = externalConfig st
c <- liftIO $ atomically $ readTVar v (ParsedRemoteConfig m c) <- liftIO $ atomically $ readTVar v
c' <- setRemoteCredPair' RemoteConfigValue id encryptionAlreadySetup c gc m' <- setRemoteCredPair' RemoteConfigValue (\m' -> ParsedRemoteConfig m' c) encryptionAlreadySetup m gc
(credstorage setting u) (credstorage setting u)
(Just (login, password)) (Just (login, password))
void $ liftIO $ atomically $ swapTVar v c' void $ liftIO $ atomically $ swapTVar v (ParsedRemoteConfig m' c)
_ -> senderror "cannot send SETCREDS here" _ -> senderror "cannot send SETCREDS here"
handleRemoteRequest (GETCREDS setting) = case (externalUUID external, externalGitConfig external) of handleRemoteRequest (GETCREDS setting) = case (externalUUID external, externalGitConfig external) of
(Just u, Just gc) -> do (Just u, Just gc) -> do

View file

@ -80,16 +80,16 @@ remote = specialRemoteType $ RemoteType
gitRepoField :: RemoteConfigField gitRepoField :: RemoteConfigField
gitRepoField = Accepted "gitrepo" gitRepoField = Accepted "gitrepo"
chainGen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) chainGen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
chainGen gcryptr u c gc rs = do chainGen gcryptr u rc gc rs = do
g <- gitRepo g <- gitRepo
-- get underlying git repo with real path, not gcrypt path -- get underlying git repo with real path, not gcrypt path
r <- liftIO $ Git.GCrypt.encryptedRemote g gcryptr r <- liftIO $ Git.GCrypt.encryptedRemote g gcryptr
let r' = r { Git.remoteName = Git.remoteName gcryptr } let r' = r { Git.remoteName = Git.remoteName gcryptr }
gen r' u c gc rs gen r' u rc gc rs
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen baser u c gc rs = do gen baser u rc gc rs = do
-- doublecheck that cache matches underlying repo's gcrypt-id -- doublecheck that cache matches underlying repo's gcrypt-id
-- (which might not be set), only for local repos -- (which might not be set), only for local repos
(mgcryptid, r) <- getGCryptId True baser gc (mgcryptid, r) <- getGCryptId True baser gc
@ -97,7 +97,9 @@ gen baser u c gc rs = do
case (mgcryptid, Git.GCrypt.remoteRepoId g (Git.remoteName baser)) of case (mgcryptid, Git.GCrypt.remoteRepoId g (Git.remoteName baser)) of
(Just gcryptid, Just cachedgcryptid) (Just gcryptid, Just cachedgcryptid)
| gcryptid /= cachedgcryptid -> resetup gcryptid r | gcryptid /= cachedgcryptid -> resetup gcryptid r
_ -> gen' r u c gc rs _ -> do
c <- parsedRemoteConfig remote rc
gen' r u c gc rs
where where
-- A different drive may have been mounted, making a different -- A different drive may have been mounted, making a different
-- gcrypt remote available. So need to set the cached -- gcrypt remote available. So need to set the cached
@ -108,10 +110,8 @@ gen baser u c gc rs = do
let u' = genUUIDInNameSpace gCryptNameSpace gcryptid let u' = genUUIDInNameSpace gCryptNameSpace gcryptid
v <- M.lookup u' <$> readRemoteLog v <- M.lookup u' <$> readRemoteLog
case (Git.remoteName baser, v) of case (Git.remoteName baser, v) of
(Just remotename, Just c') -> do (Just remotename, Just rc') -> do
pc <- either giveup return pc <- parsedRemoteConfig remote rc'
. parseRemoteConfig c'
=<< configParser remote c'
setGcryptEncryption pc remotename setGcryptEncryption pc remotename
storeUUIDIn (remoteAnnexConfig baser "uuid") u' storeUUIDIn (remoteAnnexConfig baser "uuid") u'
setConfig (Git.GCrypt.remoteConfigKey "gcrypt-id" remotename) gcryptid setConfig (Git.GCrypt.remoteConfigKey "gcrypt-id" remotename) gcryptid

View file

@ -161,20 +161,21 @@ configRead autoinit r = do
Just r' -> return r' Just r' -> return r'
_ -> return r _ -> return r
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs gen r u rc gc rs
-- Remote.GitLFS may be used with a repo that is also encrypted -- Remote.GitLFS may be used with a repo that is also encrypted
-- with gcrypt so is checked first. -- with gcrypt so is checked first.
| remoteAnnexGitLFS gc = Remote.GitLFS.gen r u c gc rs | remoteAnnexGitLFS gc = Remote.GitLFS.gen r u rc gc rs
| Git.GCrypt.isEncrypted r = Remote.GCrypt.chainGen r u c gc rs | Git.GCrypt.isEncrypted r = Remote.GCrypt.chainGen r u rc gc rs
| otherwise = case repoP2PAddress r of | otherwise = case repoP2PAddress r of
Nothing -> do Nothing -> do
st <- mkState r u gc st <- mkState r u gc
go st <$> remoteCost gc defcst c <- parsedRemoteConfig remote rc
Just addr -> Remote.P2P.chainGen addr r u c gc rs go st c <$> remoteCost gc defcst
Just addr -> Remote.P2P.chainGen addr r u rc gc rs
where where
defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost
go st cst = Just new go st c cst = Just new
where where
new = Remote new = Remote
{ uuid = u { uuid = u
@ -205,14 +206,14 @@ gen r u c gc rs
, appendonly = False , appendonly = False
, availability = availabilityCalc r , availability = availabilityCalc r
, remotetype = remote , remotetype = remote
, mkUnavailable = unavailable r u c gc rs , mkUnavailable = unavailable r u rc gc rs
, getInfo = gitRepoInfo new , getInfo = gitRepoInfo new
, claimUrl = Nothing , claimUrl = Nothing
, checkUrl = Nothing , checkUrl = Nothing
, remoteStateHandle = rs , remoteStateHandle = rs
} }
unavailable :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) unavailable :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
unavailable r = gen r' unavailable r = gen r'
where where
r' = case Git.location r of r' = case Git.location r of

View file

@ -73,8 +73,9 @@ remote = specialRemoteType $ RemoteType
urlField :: RemoteConfigField urlField :: RemoteConfigField
urlField = Accepted "url" urlField = Accepted "url"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
-- If the repo uses gcrypt, get the underlaying repo without the -- If the repo uses gcrypt, get the underlaying repo without the
-- gcrypt url, to do LFS endpoint discovery on. -- gcrypt url, to do LFS endpoint discovery on.
r' <- if Git.GCrypt.isEncrypted r r' <- if Git.GCrypt.isEncrypted r
@ -85,14 +86,18 @@ gen r u c gc rs = do
sem <- liftIO $ MSemN.new 1 sem <- liftIO $ MSemN.new 1
h <- liftIO $ newTVarIO $ LFSHandle Nothing Nothing sem r' gc h <- liftIO $ newTVarIO $ LFSHandle Nothing Nothing sem r' gc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
let specialcfg = (specialRemoteCfg c)
-- chunking would not improve git-lfs
{ chunkConfig = NoChunks
}
return $ Just $ specialRemote' specialcfg c return $ Just $ specialRemote' specialcfg c
(simplyPrepare $ store rs h) (simplyPrepare $ store rs h)
(simplyPrepare $ retrieve rs h) (simplyPrepare $ retrieve rs h)
(simplyPrepare $ remove h) (simplyPrepare $ remove h)
(simplyPrepare $ checkKey rs h) (simplyPrepare $ checkKey rs h)
(this cst) (this c cst)
where where
this cst = Remote this c cst = Remote
{ uuid = u { uuid = u
, cost = cst , cost = cst
, name = Git.repoDescribe r , name = Git.repoDescribe r
@ -122,15 +127,11 @@ gen r u c gc rs = do
-- content cannot be removed from a git-lfs repo -- content cannot be removed from a git-lfs repo
, appendonly = True , appendonly = True
, mkUnavailable = return Nothing , mkUnavailable = return Nothing
, getInfo = gitRepoInfo (this cst) , getInfo = gitRepoInfo (this c cst)
, claimUrl = Nothing , claimUrl = Nothing
, checkUrl = Nothing , checkUrl = Nothing
, remoteStateHandle = rs , remoteStateHandle = rs
} }
specialcfg = (specialRemoteCfg c)
-- chunking would not improve git-lfs
{ chunkConfig = NoChunks
}
mySetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) mySetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
mySetup _ mu _ c gc = do mySetup _ mu _ c gc = do

View file

@ -59,10 +59,12 @@ vaultField = Accepted "vault"
fileprefixField :: RemoteConfigField fileprefixField :: RemoteConfigField
fileprefixField = Accepted "fileprefix" fileprefixField = Accepted "fileprefix"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = new <$> remoteCost gc veryExpensiveRemoteCost gen r u rc gc rs = new
<$> parsedRemoteConfig remote rc
<*> remoteCost gc veryExpensiveRemoteCost
where where
new cst = Just $ specialRemote' specialcfg c new c cst = Just $ specialRemote' specialcfg c
(prepareStore this) (prepareStore this)
(prepareRetrieve this) (prepareRetrieve this)
(simplyPrepare $ remove this) (simplyPrepare $ remove this)
@ -105,10 +107,10 @@ gen r u c gc rs = new <$> remoteCost gc veryExpensiveRemoteCost
, checkUrl = Nothing , checkUrl = Nothing
, remoteStateHandle = rs , remoteStateHandle = rs
} }
specialcfg = (specialRemoteCfg c) specialcfg = (specialRemoteCfg c)
-- Disabled until jobList gets support for chunks. -- Disabled until jobList gets support for chunks.
{ chunkConfig = NoChunks { chunkConfig = NoChunks
} }
glacierSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) glacierSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
glacierSetup ss mu mcreds c gc = do glacierSetup ss mu mcreds c gc = do

View file

@ -72,15 +72,11 @@ importIsSupported = \_ _ -> return True
-- | Prevent or allow exporttree=yes and importtree=yes when -- | Prevent or allow exporttree=yes and importtree=yes when
-- setting up a new remote, depending on exportSupported and importSupported. -- setting up a new remote, depending on exportSupported and importSupported.
adjustExportImportRemoteType :: RemoteType -> RemoteType adjustExportImportRemoteType :: RemoteType -> RemoteType
adjustExportImportRemoteType rt = rt adjustExportImportRemoteType rt = rt { setup = setup' }
{ setup = setup'
, configParser = configparser
}
where where
configparser c = addRemoteConfigParser exportImportConfigParsers
<$> configParser rt c
setup' st mu cp c gc = do setup' st mu cp c gc = do
pc <- either giveup return . parseRemoteConfig c =<< configparser c pc <- either giveup return . parseRemoteConfig c
=<< configParser rt c
let checkconfig supported configured configfield cont = let checkconfig supported configured configfield cont =
ifM (supported rt pc gc) ifM (supported rt pc gc)
( case st of ( case st of
@ -89,7 +85,7 @@ adjustExportImportRemoteType rt = rt
giveup $ "cannot enable both encryption and " ++ fromProposedAccepted configfield giveup $ "cannot enable both encryption and " ++ fromProposedAccepted configfield
| otherwise -> cont | otherwise -> cont
Enable oldc -> do Enable oldc -> do
oldpc <- either mempty id . parseRemoteConfig oldc <$> configparser oldc oldpc <- parsedRemoteConfig rt oldc
if configured pc /= configured oldpc if configured pc /= configured oldpc
then giveup $ "cannot change " ++ fromProposedAccepted configfield ++ " of existing special remote" then giveup $ "cannot change " ++ fromProposedAccepted configfield ++ " of existing special remote"
else cont else cont
@ -103,14 +99,6 @@ adjustExportImportRemoteType rt = rt
then giveup "cannot enable importtree=yes without also enabling exporttree=yes" then giveup "cannot enable importtree=yes without also enabling exporttree=yes"
else setup rt st mu cp c gc else setup rt st mu cp c gc
exportImportConfigParsers :: [RemoteConfigFieldParser]
exportImportConfigParsers =
[ yesNoParser exportTreeField False
(FieldDesc "export trees of files to this remote")
, yesNoParser importTreeField False
(FieldDesc "import trees of files from this remote")
]
-- | Adjust a remote to support exporttree=yes and importree=yes. -- | Adjust a remote to support exporttree=yes and importree=yes.
-- --
-- Note that all remotes with importree=yes also have exporttree=yes. -- Note that all remotes with importree=yes also have exporttree=yes.

View file

@ -45,8 +45,9 @@ remote = specialRemoteType $ RemoteType
hooktypeField :: RemoteConfigField hooktypeField :: RemoteConfigField
hooktypeField = Accepted "hooktype" hooktypeField = Accepted "hooktype"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
return $ Just $ specialRemote c return $ Just $ specialRemote c
(simplyPrepare $ store hooktype) (simplyPrepare $ store hooktype)
@ -80,7 +81,7 @@ gen r u c gc rs = do
, appendonly = False , appendonly = False
, availability = GloballyAvailable , availability = GloballyAvailable
, remotetype = remote , remotetype = remote
, mkUnavailable = gen r u c , mkUnavailable = gen r u rc
(gc { remoteAnnexHookType = Just "!dne!" }) (gc { remoteAnnexHookType = Just "!dne!" })
rs rs
, getInfo = return [("hooktype", hooktype)] , getInfo = return [("hooktype", hooktype)]

View file

@ -20,7 +20,6 @@ import Annex.UUID
import Remote.Helper.Hooks import Remote.Helper.Hooks
import Remote.Helper.ReadOnly import Remote.Helper.ReadOnly
import Remote.Helper.ExportImport import Remote.Helper.ExportImport
import Annex.SpecialRemote.Config
import qualified Git import qualified Git
import qualified Git.Config import qualified Git.Config
@ -110,8 +109,7 @@ remoteGen m t g = do
let cu = fromMaybe u $ remoteAnnexConfigUUID gc let cu = fromMaybe u $ remoteAnnexConfigUUID gc
let rs = RemoteStateHandle cu let rs = RemoteStateHandle cu
let c = fromMaybe M.empty $ M.lookup cu m let c = fromMaybe M.empty $ M.lookup cu m
pc <- either (const mempty) id . parseRemoteConfig c <$> configParser t c generate t g u c gc rs >>= \case
generate t g u pc gc rs >>= \case
Nothing -> return Nothing Nothing -> return Nothing
Just r -> Just <$> adjustExportImport (adjustReadOnly (addHooks r)) rs Just r -> Just <$> adjustExportImport (adjustReadOnly (addHooks r)) rs

View file

@ -26,6 +26,7 @@ import Remote.Helper.Git
import Remote.Helper.ExportImport import Remote.Helper.ExportImport
import Remote.Helper.P2P import Remote.Helper.P2P
import Utility.AuthToken import Utility.AuthToken
import Annex.SpecialRemote.Config
import Control.Concurrent.STM import Control.Concurrent.STM
@ -42,8 +43,9 @@ remote = RemoteType
, importSupported = importUnsupported , importSupported = importUnsupported
} }
chainGen :: P2PAddress -> Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) chainGen :: P2PAddress -> Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
chainGen addr r u c gc rs = do chainGen addr r u rc gc rs = do
c <- parsedRemoteConfig remote rc
connpool <- mkConnectionPool connpool <- mkConnectionPool
cst <- remoteCost gc veryExpensiveRemoteCost cst <- remoteCost gc veryExpensiveRemoteCost
let protorunner = runProto u addr connpool let protorunner = runProto u addr connpool

View file

@ -67,13 +67,17 @@ shellEscapeField = Accepted "shellescape"
rsyncUrlField :: RemoteConfigField rsyncUrlField :: RemoteConfigField
rsyncUrlField = Accepted "rsyncurl" rsyncUrlField = Accepted "rsyncurl"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
(transport, url) <- rsyncTransport gc $ (transport, url) <- rsyncTransport gc $
fromMaybe (giveup "missing rsyncurl") $ remoteAnnexRsyncUrl gc fromMaybe (giveup "missing rsyncurl") $ remoteAnnexRsyncUrl gc
let o = genRsyncOpts c gc transport url let o = genRsyncOpts c gc transport url
let islocal = rsyncUrlIsPath $ rsyncUrl o let islocal = rsyncUrlIsPath $ rsyncUrl o
let specialcfg = (specialRemoteCfg c)
-- Rsync displays its own progress.
{ displayProgress = False }
return $ Just $ specialRemote' specialcfg c return $ Just $ specialRemote' specialcfg c
(simplyPrepare $ fileStorer $ store o) (simplyPrepare $ fileStorer $ store o)
(simplyPrepare $ fileRetriever $ retrieve o) (simplyPrepare $ fileRetriever $ retrieve o)
@ -119,10 +123,6 @@ gen r u c gc rs = do
, checkUrl = Nothing , checkUrl = Nothing
, remoteStateHandle = rs , remoteStateHandle = rs
} }
where
specialcfg = (specialRemoteCfg c)
-- Rsync displays its own progress.
{ displayProgress = False }
-- Things used by genRsyncOpts -- Things used by genRsyncOpts
rsyncRemoteConfigs :: [RemoteConfigFieldParser] rsyncRemoteConfigs :: [RemoteConfigFieldParser]

View file

@ -154,15 +154,16 @@ portField = Accepted "port"
mungekeysField :: RemoteConfigField mungekeysField :: RemoteConfigField
mungekeysField = Accepted "mungekeys" mungekeysField = Accepted "mungekeys"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
info <- extractS3Info c info <- extractS3Info c
hdl <- mkS3HandleVar c gc u hdl <- mkS3HandleVar c gc u
magic <- liftIO initMagicMime magic <- liftIO initMagicMime
return $ new cst info hdl magic return $ new c cst info hdl magic
where where
new cst info hdl magic = Just $ specialRemote c new c cst info hdl magic = Just $ specialRemote c
(simplyPrepare $ store hdl this info magic) (simplyPrepare $ store hdl this info magic)
(simplyPrepare $ retrieve hdl this rs c info) (simplyPrepare $ retrieve hdl this rs c info)
(simplyPrepare $ remove hdl this info) (simplyPrepare $ remove hdl this info)
@ -211,7 +212,7 @@ gen r u c gc rs = do
, appendonly = versioning info , appendonly = versioning info
, availability = GloballyAvailable , availability = GloballyAvailable
, remotetype = remote , remotetype = remote
, mkUnavailable = gen r u (M.insert hostField (RemoteConfigValue ("!dne!" :: String)) c) gc rs , mkUnavailable = gen r u (M.insert hostField (Proposed "!dne!") rc) gc rs
, getInfo = includeCredsInfo c (AWS.creds u) (s3Info c info) , getInfo = includeCredsInfo c (AWS.creds u) (s3Info c info)
, claimUrl = Nothing , claimUrl = Nothing
, checkUrl = Nothing , checkUrl = Nothing
@ -1249,9 +1250,7 @@ enableBucketVersioning ss info _ _ _ = do
Init -> when (versioning info) $ Init -> when (versioning info) $
enableversioning (bucket info) enableversioning (bucket info)
Enable oldc -> do Enable oldc -> do
oldpc <- either (const mempty) id oldpc <- parsedRemoteConfig remote oldc
. parseRemoteConfig oldc
<$> configParser remote oldc
oldinfo <- extractS3Info oldpc oldinfo <- extractS3Info oldpc
when (versioning info /= versioning oldinfo) $ when (versioning info /= versioning oldinfo) $
giveup "Cannot change versioning= of existing S3 remote." giveup "Cannot change versioning= of existing S3 remote."

View file

@ -74,8 +74,9 @@ scsField = Accepted "shared-convergence-secret"
furlField :: RemoteConfigField furlField :: RemoteConfigField
furlField = Accepted "introducer-furl" furlField = Accepted "introducer-furl"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = do gen r u rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
hdl <- liftIO $ TahoeHandle hdl <- liftIO $ TahoeHandle
<$> maybe (defaultTahoeConfigDir u) return (remoteAnnexTahoe gc) <$> maybe (defaultTahoeConfigDir u) return (remoteAnnexTahoe gc)

View file

@ -21,6 +21,7 @@ import Annex.UUID
import Utility.Metered import Utility.Metered
import qualified Annex.Url as Url import qualified Annex.Url as Url
import Annex.YoutubeDl import Annex.YoutubeDl
import Annex.SpecialRemote.Config
remote :: RemoteType remote :: RemoteType
remote = RemoteType remote = RemoteType
@ -41,8 +42,9 @@ list _autoinit = do
r <- liftIO $ Git.Construct.remoteNamed "web" (pure Git.Construct.fromUnknown) r <- liftIO $ Git.Construct.remoteNamed "web" (pure Git.Construct.fromUnknown)
return [r] return [r]
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r _ c gc rs = do gen r _ rc gc rs = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost cst <- remoteCost gc expensiveRemoteCost
return $ Just Remote return $ Just Remote
{ uuid = webUUID { uuid = webUUID

View file

@ -63,10 +63,12 @@ urlField = Accepted "url"
davcredsField :: RemoteConfigField davcredsField :: RemoteConfigField
davcredsField = Accepted "davcreds" davcredsField = Accepted "davcreds"
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
gen r u c gc rs = new <$> remoteCost gc expensiveRemoteCost gen r u rc gc rs = new
<$> parsedRemoteConfig remote rc
<*> remoteCost gc expensiveRemoteCost
where where
new cst = Just $ specialRemote c new c cst = Just $ specialRemote c
(prepareDAV this $ store chunkconfig) (prepareDAV this $ store chunkconfig)
(prepareDAV this $ retrieve chunkconfig) (prepareDAV this $ retrieve chunkconfig)
(prepareDAV this $ remove) (prepareDAV this $ remove)
@ -108,7 +110,7 @@ gen r u c gc rs = new <$> remoteCost gc expensiveRemoteCost
, appendonly = False , appendonly = False
, availability = GloballyAvailable , availability = GloballyAvailable
, remotetype = remote , remotetype = remote
, mkUnavailable = gen r u (M.insert urlField (RemoteConfigValue "http://!dne!/") c) gc rs , mkUnavailable = gen r u (M.insert urlField (Proposed "http://!dne!/") rc) gc rs
, getInfo = includeCredsInfo c (davCreds u) $ , getInfo = includeCredsInfo c (davCreds u) $
[("url", fromMaybe "unknown" $ getRemoteConfigValue urlField c)] [("url", fromMaybe "unknown" $ getRemoteConfigValue urlField c)]
, claimUrl = Nothing , claimUrl = Nothing

View file

@ -1622,7 +1622,7 @@ test_crypto = do
checkKeys cip (Just v) <&&> checkCipher encipher ks' checkKeys cip (Just v) <&&> checkCipher encipher ks'
_ -> return False _ -> return False
where where
pc =either mempty id $ pc = either (const (Types.Remote.ParsedRemoteConfig mempty mempty)) id $
Remote.Helper.Encryptable.parseEncryptionConfig c Remote.Helper.Encryptable.parseEncryptionConfig c
keysMatch (Utility.Gpg.KeyIds ks') = keysMatch (Utility.Gpg.KeyIds ks') =
maybe False (\(Utility.Gpg.KeyIds ks2) -> maybe False (\(Utility.Gpg.KeyIds ks2) ->
@ -1632,7 +1632,7 @@ test_crypto = do
checkScheme Types.Crypto.PubKey = scheme == "pubkey" checkScheme Types.Crypto.PubKey = scheme == "pubkey"
checkKeys cip mvariant = do checkKeys cip mvariant = do
dummycfg <- Types.GitConfig.dummyRemoteGitConfig dummycfg <- Types.GitConfig.dummyRemoteGitConfig
let encparams = (mempty :: Types.Remote.ParsedRemoteConfig, dummycfg) let encparams = (Types.Remote.ParsedRemoteConfig mempty mempty, dummycfg)
cipher <- Crypto.decryptCipher gpgcmd encparams cip cipher <- Crypto.decryptCipher gpgcmd encparams cip
files <- filterM doesFileExist $ files <- filterM doesFileExist $
map ("dir" </>) $ concatMap (serializeKeys cipher) keys map ("dir" </>) $ concatMap (serializeKeys cipher) keys

View file

@ -58,7 +58,7 @@ data RemoteTypeA a = RemoteType
-- The Bool is True if automatic initialization of remotes is desired -- The Bool is True if automatic initialization of remotes is desired
, enumerate :: Bool -> a [Git.Repo] , enumerate :: Bool -> a [Git.Repo]
-- generates a remote of this type -- generates a remote of this type
, generate :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> a (Maybe (RemoteA a)) , generate :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> a (Maybe (RemoteA a))
-- parse configs of remotes of this type -- parse configs of remotes of this type
, configParser :: RemoteConfig -> a RemoteConfigParser , configParser :: RemoteConfig -> a RemoteConfigParser
-- initializes or enables a remote -- initializes or enables a remote

View file

@ -22,7 +22,9 @@ type RemoteConfigField = ProposedAccepted String
type RemoteConfig = M.Map RemoteConfigField (ProposedAccepted String) type RemoteConfig = M.Map RemoteConfigField (ProposedAccepted String)
{- Before being used a RemoteConfig has to be parsed. -} {- Before being used a RemoteConfig has to be parsed. -}
type ParsedRemoteConfig = M.Map RemoteConfigField RemoteConfigValue data ParsedRemoteConfig = ParsedRemoteConfig
(M.Map RemoteConfigField RemoteConfigValue)
RemoteConfig
{- Remotes can have configuration values of many types, so use Typeable {- Remotes can have configuration values of many types, so use Typeable
- to let them all be stored in here. -} - to let them all be stored in here. -}