move untrust forcing from Logs.Trust into Remote
No behavior changes here, but this is groundwork for letting remotes such as borg vary untrust forcing depending on configuration.
This commit is contained in:
parent
5ce7fce74a
commit
36133f27c0
22 changed files with 42 additions and 13 deletions
|
@ -64,22 +64,15 @@ trustMap = maybe trustMapLoad return =<< Annex.getState Annex.trustmap
|
||||||
{- Loads the map, updating the cache, -}
|
{- Loads the map, updating the cache, -}
|
||||||
trustMapLoad :: Annex TrustMap
|
trustMapLoad :: Annex TrustMap
|
||||||
trustMapLoad = do
|
trustMapLoad = do
|
||||||
overrides <- Annex.getState Annex.forcetrust
|
forceoverrides <- Annex.getState Annex.forcetrust
|
||||||
l <- remoteList
|
l <- remoteList
|
||||||
-- Export/import remotes are normally untrusted, because they are
|
let untrustoverrides = M.fromList $
|
||||||
-- not key/value stores and there are many ways that content stored
|
map (\r -> (Types.Remote.uuid r, UnTrusted))
|
||||||
-- on them can be lost. An exception is ones with versionedExport set.
|
(filter Types.Remote.untrustworthy l)
|
||||||
let isexportimport r = Types.Remote.isExportSupported r
|
|
||||||
<||> Types.Remote.isImportSupported r
|
|
||||||
let isuntrustworthy r = isexportimport r
|
|
||||||
<&&> pure (not (Types.Remote.versionedExport (Types.Remote.exportActions r)))
|
|
||||||
untrustworthy <- filterM isuntrustworthy l
|
|
||||||
let trustoverrides = M.fromList $
|
|
||||||
map (\r -> (Types.Remote.uuid r, UnTrusted)) untrustworthy
|
|
||||||
logged <- trustMapRaw
|
logged <- trustMapRaw
|
||||||
let configured = M.fromList $ mapMaybe configuredtrust l
|
let configured = M.fromList $ mapMaybe configuredtrust l
|
||||||
let m = M.unionWith min trustoverrides $
|
let m = M.unionWith min untrustoverrides $
|
||||||
M.union overrides $
|
M.union forceoverrides $
|
||||||
M.union configured logged
|
M.union configured logged
|
||||||
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
|
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -101,6 +101,7 @@ gen r u rc gc rs = do
|
||||||
, availability = LocallyAvailable
|
, availability = LocallyAvailable
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
, getInfo = return
|
, getInfo = return
|
||||||
[ ("androidserial", fromAndroidSerial serial)
|
[ ("androidserial", fromAndroidSerial serial)
|
||||||
|
|
|
@ -86,6 +86,7 @@ gen r _ rc gc rs = do
|
||||||
, getRepo = return r
|
, getRepo = return r
|
||||||
, readonly = True
|
, readonly = True
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -108,6 +108,7 @@ gen r u rc gc rs = do
|
||||||
, availability = if borgLocal borgrepo then LocallyAvailable else GloballyAvailable
|
, availability = if borgLocal borgrepo then LocallyAvailable else GloballyAvailable
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = True
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
, getInfo = return [("repo", borgrepo)]
|
, getInfo = return [("repo", borgrepo)]
|
||||||
, claimUrl = Nothing
|
, claimUrl = Nothing
|
||||||
|
|
|
@ -95,6 +95,7 @@ gen r u rc gc rs = do
|
||||||
, availability = if bupLocal buprepo then LocallyAvailable else GloballyAvailable
|
, availability = if bupLocal buprepo then LocallyAvailable else GloballyAvailable
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
, getInfo = return [("repo", buprepo)]
|
, getInfo = return [("repo", buprepo)]
|
||||||
, claimUrl = Nothing
|
, claimUrl = Nothing
|
||||||
|
|
|
@ -98,6 +98,7 @@ gen r u rc gc rs = do
|
||||||
, availability = if ddarLocal ddarrepo then LocallyAvailable else GloballyAvailable
|
, availability = if ddarLocal ddarrepo then LocallyAvailable else GloballyAvailable
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
, getInfo = return [("repo", ddarRepoLocation ddarrepo)]
|
, getInfo = return [("repo", ddarRepoLocation ddarrepo)]
|
||||||
, claimUrl = Nothing
|
, claimUrl = Nothing
|
||||||
|
|
|
@ -115,6 +115,7 @@ gen r u rc gc rs = do
|
||||||
, localpath = Just dir'
|
, localpath = Just dir'
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = LocallyAvailable
|
, availability = LocallyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = gen r u rc
|
, mkUnavailable = gen r u rc
|
||||||
|
|
|
@ -144,6 +144,7 @@ gen r u rc gc rs
|
||||||
, gitconfig = gc
|
, gitconfig = gc
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = avail
|
, availability = avail
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
{ exportSupported = cheapexportsupported }
|
{ exportSupported = cheapexportsupported }
|
||||||
|
|
|
@ -153,6 +153,7 @@ gen' r u c gc rs = do
|
||||||
, gitconfig = gc
|
, gitconfig = gc
|
||||||
, readonly = Git.repoIsHttp r
|
, readonly = Git.repoIsHttp r
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = availabilityCalc r
|
, availability = availabilityCalc r
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -205,6 +205,7 @@ gen r u rc gc rs
|
||||||
, gitconfig = gc
|
, gitconfig = gc
|
||||||
, readonly = Git.repoIsHttp r
|
, readonly = Git.repoIsHttp r
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = availabilityCalc r
|
, availability = availabilityCalc r
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = unavailable r u rc gc rs
|
, mkUnavailable = unavailable r u rc gc rs
|
||||||
|
|
|
@ -133,6 +133,7 @@ gen r u rc gc rs = do
|
||||||
, readonly = False
|
, readonly = False
|
||||||
-- content cannot be removed from a git-lfs repo
|
-- content cannot be removed from a git-lfs repo
|
||||||
, appendonly = True
|
, appendonly = True
|
||||||
|
, untrustworthy = False
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
, getInfo = gitRepoInfo (this c cst h)
|
, getInfo = gitRepoInfo (this c cst h)
|
||||||
, claimUrl = Nothing
|
, claimUrl = Nothing
|
||||||
|
|
|
@ -99,6 +99,7 @@ gen r u rc gc rs = new
|
||||||
, localpath = Nothing
|
, localpath = Nothing
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -204,6 +204,16 @@ adjustExportImport' isexport isimport r rs = do
|
||||||
-- in confusing ways when there's an export
|
-- in confusing ways when there's an export
|
||||||
-- conflict (or an import conflict).
|
-- conflict (or an import conflict).
|
||||||
, checkPresentCheap = False
|
, checkPresentCheap = False
|
||||||
|
-- Export/import remotes can lose content stored on them in
|
||||||
|
-- many ways. This is not a problem with versioned
|
||||||
|
-- ones though, since they still allow accessing by Key.
|
||||||
|
-- And for thirdPartyPopulated, it depends on how the
|
||||||
|
-- content gets actually stored in the remote, so
|
||||||
|
-- is not overriddden here.
|
||||||
|
, untrustworthy =
|
||||||
|
if versioned || thirdPartyPopulated (remotetype r)
|
||||||
|
then untrustworthy r
|
||||||
|
else False
|
||||||
-- git-annex testremote cannot be used to test
|
-- git-annex testremote cannot be used to test
|
||||||
-- import/export since it stores keys.
|
-- import/export since it stores keys.
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -80,6 +80,7 @@ gen r u rc gc rs = do
|
||||||
, gitconfig = gc
|
, gitconfig = gc
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = gen r u rc
|
, mkUnavailable = gen r u rc
|
||||||
|
|
|
@ -88,6 +88,7 @@ gen r u rc gc rs = do
|
||||||
, getRepo = return r
|
, getRepo = return r
|
||||||
, readonly = True
|
, readonly = True
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -74,6 +74,7 @@ chainGen addr r u rc gc rs = do
|
||||||
, gitconfig = gc
|
, gitconfig = gc
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -118,6 +118,7 @@ gen r u rc gc rs = do
|
||||||
else Nothing
|
else Nothing
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = if islocal then LocallyAvailable else GloballyAvailable
|
, availability = if islocal then LocallyAvailable else GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -234,6 +234,7 @@ gen r u rc gc rs = do
|
||||||
, localpath = Nothing
|
, localpath = Nothing
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = gen r u (M.insert hostField (Proposed "!dne!") rc) gc rs
|
, mkUnavailable = gen r u (M.insert hostField (Proposed "!dne!") rc) gc rs
|
||||||
|
|
|
@ -107,6 +107,7 @@ gen r u rc gc rs = do
|
||||||
, localpath = Nothing
|
, localpath = Nothing
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -72,6 +72,7 @@ gen r _ rc gc rs = do
|
||||||
, getRepo = return r
|
, getRepo = return r
|
||||||
, readonly = True
|
, readonly = True
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = return Nothing
|
, mkUnavailable = return Nothing
|
||||||
|
|
|
@ -115,6 +115,7 @@ gen r u rc gc rs = do
|
||||||
, localpath = Nothing
|
, localpath = Nothing
|
||||||
, readonly = False
|
, readonly = False
|
||||||
, appendonly = False
|
, appendonly = False
|
||||||
|
, untrustworthy = False
|
||||||
, availability = GloballyAvailable
|
, availability = GloballyAvailable
|
||||||
, remotetype = remote
|
, remotetype = remote
|
||||||
, mkUnavailable = gen r u (M.insert urlField (Proposed "http://!dne!/") rc) gc rs
|
, mkUnavailable = gen r u (M.insert urlField (Proposed "http://!dne!/") rc) gc rs
|
||||||
|
|
|
@ -143,6 +143,13 @@ data RemoteA a = Remote
|
||||||
-- a Remote can allow writes but not have a way to delete content
|
-- a Remote can allow writes but not have a way to delete content
|
||||||
-- from it.
|
-- from it.
|
||||||
, appendonly :: Bool
|
, appendonly :: Bool
|
||||||
|
-- Set if a remote cannot be trusted to continue to contain the
|
||||||
|
-- contents of files stored there. Notably, most export/import
|
||||||
|
-- remotes are untrustworthy because they are not key/value stores.
|
||||||
|
-- Since this prevents the user from adjusting a remote's trust
|
||||||
|
-- level, it's often better not not set it and instead let the user
|
||||||
|
-- decide.
|
||||||
|
, untrustworthy :: Bool
|
||||||
-- a Remote can be globally available. (Ie, "in the cloud".)
|
-- a Remote can be globally available. (Ie, "in the cloud".)
|
||||||
, availability :: Availability
|
, availability :: Availability
|
||||||
-- the type of the remote
|
-- the type of the remote
|
||||||
|
|
Loading…
Reference in a new issue