summaryrefslogtreecommitdiff
path: root/Remote/Helper/ReadOnly.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-08-17 11:21:38 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-08-17 11:21:38 -0400
commita5cb01cd4f6e90786ef738e7d666ff363e5b6828 (patch)
tree8c823b0143785b4c6ff282a61f51508423fd9afe /Remote/Helper/ReadOnly.hs
parentd7337c96cf31ef0a0ff45db399cd787c778fdd28 (diff)
export some always failing methods for readonly remotes
Diffstat (limited to 'Remote/Helper/ReadOnly.hs')
-rw-r--r--Remote/Helper/ReadOnly.hs33
1 files changed, 25 insertions, 8 deletions
diff --git a/Remote/Helper/ReadOnly.hs b/Remote/Helper/ReadOnly.hs
index 2e327a040..c0330e453 100644
--- a/Remote/Helper/ReadOnly.hs
+++ b/Remote/Helper/ReadOnly.hs
@@ -1,14 +1,21 @@
{- Adds readonly support to remotes.
-
- - Copyright 2013 Joey Hess <id@joeyh.name>
+ - Copyright 2013, 2015 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
-module Remote.Helper.ReadOnly (adjustReadOnly) where
+module Remote.Helper.ReadOnly
+ ( adjustReadOnly
+ , readonlyStoreKey
+ , readonlyStorer
+ , readonlyRemoveKey
+ ) where
import Common.Annex
import Types.Remote
+import Types.StoreRetrieve
+import Utility.Metered
{- Adds support for read-only remotes, by replacing the
- methods that write to a remote with dummies that fail.
@@ -18,12 +25,22 @@ import Types.Remote
adjustReadOnly :: Remote -> Remote
adjustReadOnly r
| remoteAnnexReadOnly (gitconfig r) = r
- { storeKey = \_ _ _ -> failbool
- , removeKey = \_ -> failbool
+ { storeKey = readonlyStoreKey
+ , removeKey = readonlyRemoveKey
, repairRepo = Nothing
}
| otherwise = r
- where
- failbool = do
- warning "this remote is readonly"
- return False
+
+readonlyStoreKey :: Key -> AssociatedFile -> MeterUpdate -> Annex Bool
+readonlyStoreKey _ _ _ = readonlyFail
+
+readonlyRemoveKey :: Key -> Annex Bool
+readonlyRemoveKey _ = readonlyFail
+
+readonlyStorer :: Storer
+readonlyStorer _ _ _ = readonlyFail
+
+readonlyFail :: Annex Bool
+readonlyFail = do
+ warning "this remote is readonly"
+ return False