prevent action or step from simulating running on a special remote
Without any connections, the step command will not try to do any actions on a special remote. But even without any connections, it's still possible for a drop action explicitly run "on" the special remote to do, when numcopies = 0 or there is a trusted repo. So guard all actions against running on a special remote too.
This commit is contained in:
parent
7cc4312695
commit
ee3d6502bb
1 changed files with 17 additions and 5 deletions
22
Annex/Sim.hs
22
Annex/Sim.hs
|
@ -337,6 +337,11 @@ applySimCommand' (CommandUse reponame s) st repobyname =
|
||||||
applySimCommand' (CommandConnect connections) st repobyname =
|
applySimCommand' (CommandConnect connections) st repobyname =
|
||||||
let (repo, remote, mconnections) = getConnection connections
|
let (repo, remote, mconnections) = getConnection connections
|
||||||
in checkKnownRepo repo st $ \u ->
|
in checkKnownRepo repo st $ \u ->
|
||||||
|
if maybe False simIsSpecialRemote (M.lookup u (simRepoState st))
|
||||||
|
then Left $ fromRepoName repo ++ " is a special remote, and cannot connect to " ++ fromRemoteName remote
|
||||||
|
else go u remote mconnections
|
||||||
|
where
|
||||||
|
go u remote mconnections =
|
||||||
let st' = st
|
let st' = st
|
||||||
{ simConnections =
|
{ simConnections =
|
||||||
let s = case M.lookup u (simConnections st) of
|
let s = case M.lookup u (simConnections st) of
|
||||||
|
@ -554,14 +559,14 @@ getSimActionComponents
|
||||||
-> SimState SimRepo
|
-> SimState SimRepo
|
||||||
-> Either String (Either (SimState SimRepo, [SimState SimRepo -> Annex (SimState SimRepo, Bool)]) (SimState SimRepo))
|
-> Either String (Either (SimState SimRepo, [SimState SimRepo -> Annex (SimState SimRepo, Bool)]) (SimState SimRepo))
|
||||||
getSimActionComponents (ActionGetWanted repo remote) st =
|
getSimActionComponents (ActionGetWanted repo remote) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepoNotSpecialRemote repo st $ \u ->
|
||||||
let go _remoteu f k _r st' = setPresentKey True u k u $
|
let go _remoteu f k _r st' = setPresentKey True u k u $
|
||||||
addHistory st' $ CommandPresent repo f
|
addHistory st' $ CommandPresent repo f
|
||||||
in overFilesRemote repo u remote S.member S.notMember wanted go st
|
in overFilesRemote repo u remote S.member S.notMember wanted go st
|
||||||
where
|
where
|
||||||
wanted k f _ = wantGet NoLiveUpdate False k f
|
wanted k f _ = wantGet NoLiveUpdate False k f
|
||||||
getSimActionComponents (ActionSendWanted repo remote) st =
|
getSimActionComponents (ActionSendWanted repo remote) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepoNotSpecialRemote repo st $ \u ->
|
||||||
overFilesRemote repo u remote S.notMember S.member wanted (go u) st
|
overFilesRemote repo u remote S.notMember S.member wanted (go u) st
|
||||||
where
|
where
|
||||||
wanted = wantGetBy NoLiveUpdate False
|
wanted = wantGetBy NoLiveUpdate False
|
||||||
|
@ -572,18 +577,18 @@ getSimActionComponents (ActionSendWanted repo remote) st =
|
||||||
setPresentKey True remoteu k u $
|
setPresentKey True remoteu k u $
|
||||||
addHistory st' $ CommandPresent (remoteNameToRepoName remote) f
|
addHistory st' $ CommandPresent (remoteNameToRepoName remote) f
|
||||||
getSimActionComponents (ActionDropUnwanted repo Nothing) st =
|
getSimActionComponents (ActionDropUnwanted repo Nothing) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepoNotSpecialRemote repo st $ \u ->
|
||||||
simulateDropUnwanted st u repo u
|
simulateDropUnwanted st u repo u
|
||||||
getSimActionComponents (ActionDropUnwanted repo (Just remote)) st =
|
getSimActionComponents (ActionDropUnwanted repo (Just remote)) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepo repo st $ \u ->
|
||||||
checkKnownRemote remote repo u st $ \ru ->
|
checkKnownRemote remote repo u st $ \ru ->
|
||||||
simulateDropUnwanted st u (remoteNameToRepoName remote) ru
|
simulateDropUnwanted st u (remoteNameToRepoName remote) ru
|
||||||
getSimActionComponents (ActionGitPush repo remote) st =
|
getSimActionComponents (ActionGitPush repo remote) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepoNotSpecialRemote repo st $ \u ->
|
||||||
checkKnownRemote remote repo u st $ \_ ->
|
checkKnownRemote remote repo u st $ \_ ->
|
||||||
simulateGitAnnexMerge repo (remoteNameToRepoName remote) st
|
simulateGitAnnexMerge repo (remoteNameToRepoName remote) st
|
||||||
getSimActionComponents (ActionGitPull repo remote) st =
|
getSimActionComponents (ActionGitPull repo remote) st =
|
||||||
checkKnownRepo repo st $ \u ->
|
checkKnownRepoNotSpecialRemote repo st $ \u ->
|
||||||
checkKnownRemote remote repo u st $ \_ ->
|
checkKnownRemote remote repo u st $ \_ ->
|
||||||
simulateGitAnnexMerge (remoteNameToRepoName remote) repo st
|
simulateGitAnnexMerge (remoteNameToRepoName remote) repo st
|
||||||
getSimActionComponents (ActionWhile a b) st =
|
getSimActionComponents (ActionWhile a b) st =
|
||||||
|
@ -768,6 +773,13 @@ checkKnownRepo reponame st a = case M.lookup reponame (simRepos st) of
|
||||||
++ fromRepoName reponame ++ "\". Choose from: "
|
++ fromRepoName reponame ++ "\". Choose from: "
|
||||||
++ unwords (map fromRepoName $ M.keys (simRepos st))
|
++ unwords (map fromRepoName $ M.keys (simRepos st))
|
||||||
|
|
||||||
|
checkKnownRepoNotSpecialRemote :: RepoName -> SimState SimRepo -> (UUID -> Either String a) -> Either String a
|
||||||
|
checkKnownRepoNotSpecialRemote reponame st a =
|
||||||
|
checkKnownRepo reponame st $ \u ->
|
||||||
|
if maybe False simIsSpecialRemote (M.lookup u (simRepoState st))
|
||||||
|
then Left $ fromRepoName reponame ++ " is a special remote, so git-annex cannot run on it."
|
||||||
|
else a u
|
||||||
|
|
||||||
checkKnownRemote :: RemoteName -> RepoName -> UUID -> SimState SimRepo -> (UUID -> Either String a) -> Either String a
|
checkKnownRemote :: RemoteName -> RepoName -> UUID -> SimState SimRepo -> (UUID -> Either String a) -> Either String a
|
||||||
checkKnownRemote remotename reponame u st a =
|
checkKnownRemote remotename reponame u st a =
|
||||||
let rs = fromMaybe mempty $ M.lookup u (simConnections st)
|
let rs = fromMaybe mempty $ M.lookup u (simConnections st)
|
||||||
|
|
Loading…
Reference in a new issue