2014-01-02 17:12:32 +00:00
|
|
|
{- Adds readonly support to remotes.
|
|
|
|
-
|
2015-08-17 15:21:38 +00:00
|
|
|
- Copyright 2013, 2015 Joey Hess <id@joeyh.name>
|
2014-01-02 17:12:32 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2015-08-17 15:21:38 +00:00
|
|
|
module Remote.Helper.ReadOnly
|
|
|
|
( adjustReadOnly
|
|
|
|
, readonlyStoreKey
|
|
|
|
, readonlyStorer
|
|
|
|
, readonlyRemoveKey
|
|
|
|
) where
|
2014-01-02 17:12:32 +00:00
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import Types.Remote
|
2015-08-17 15:21:38 +00:00
|
|
|
import Types.StoreRetrieve
|
|
|
|
import Utility.Metered
|
2014-01-02 17:12:32 +00:00
|
|
|
|
|
|
|
{- Adds support for read-only remotes, by replacing the
|
|
|
|
- methods that write to a remote with dummies that fail.
|
|
|
|
-
|
|
|
|
- Note that disabling git pushes to remotes is not handled here.
|
|
|
|
-}
|
|
|
|
adjustReadOnly :: Remote -> Remote
|
|
|
|
adjustReadOnly r
|
|
|
|
| remoteAnnexReadOnly (gitconfig r) = r
|
2015-08-17 15:21:38 +00:00
|
|
|
{ storeKey = readonlyStoreKey
|
|
|
|
, removeKey = readonlyRemoveKey
|
2014-01-02 17:12:32 +00:00
|
|
|
, repairRepo = Nothing
|
|
|
|
}
|
|
|
|
| otherwise = r
|
2015-08-17 15:21:38 +00:00
|
|
|
|
|
|
|
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
|