hook: use ChunkedEncryptable
This commit is contained in:
parent
d4dc1bce75
commit
7f5cd868d7
3 changed files with 16 additions and 29 deletions
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
module Remote.Hook (remote) where
|
module Remote.Hook (remote) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -17,12 +16,9 @@ import Types.Creds
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import Config
|
import Config
|
||||||
import Config.Cost
|
import Config.Cost
|
||||||
import Annex.Content
|
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Remote.Helper.Special
|
import Remote.Helper.Special
|
||||||
import Remote.Helper.Encryptable
|
import Remote.Helper.ChunkedEncryptable
|
||||||
import Crypto
|
|
||||||
import Utility.Metered
|
|
||||||
import Utility.Env
|
import Utility.Env
|
||||||
|
|
||||||
type Action = String
|
type Action = String
|
||||||
|
@ -39,15 +35,15 @@ remote = RemoteType {
|
||||||
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
|
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
|
||||||
gen r u c gc = do
|
gen r u c gc = do
|
||||||
cst <- remoteCost gc expensiveRemoteCost
|
cst <- remoteCost gc expensiveRemoteCost
|
||||||
return $ Just $ encryptableRemote c
|
return $ Just $ chunkedEncryptableRemote c
|
||||||
(storeEncrypted hooktype $ getGpgEncParams (c,gc))
|
(simplyPrepare $ store hooktype)
|
||||||
(retrieveEncrypted hooktype)
|
(simplyPrepare $ retrieve hooktype)
|
||||||
Remote {
|
Remote {
|
||||||
uuid = u,
|
uuid = u,
|
||||||
cost = cst,
|
cost = cst,
|
||||||
name = Git.repoDescribe r,
|
name = Git.repoDescribe r,
|
||||||
storeKey = store hooktype,
|
storeKey = storeKeyDummy,
|
||||||
retrieveKeyFile = retrieve hooktype,
|
retrieveKeyFile = retreiveKeyFileDummy,
|
||||||
retrieveKeyFileCheap = retrieveCheap hooktype,
|
retrieveKeyFileCheap = retrieveCheap hooktype,
|
||||||
removeKey = remove hooktype,
|
removeKey = remove hooktype,
|
||||||
hasKey = checkPresent r hooktype,
|
hasKey = checkPresent r hooktype,
|
||||||
|
@ -118,30 +114,18 @@ runHook hook action k f a = maybe (return False) run =<< lookupHook hook action
|
||||||
return False
|
return False
|
||||||
)
|
)
|
||||||
|
|
||||||
store :: HookName -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
store :: HookName -> Storer
|
||||||
store h k _f _p = sendAnnex k (void $ remove h k) $ \src ->
|
store h = fileStorer $ \k src _p ->
|
||||||
runHook h "store" k (Just src) $ return True
|
runHook h "store" k (Just src) $ return True
|
||||||
|
|
||||||
storeEncrypted :: HookName -> [CommandParam] -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool
|
retrieve :: HookName -> Retriever
|
||||||
storeEncrypted h gpgOpts (cipher, enck) k _p = withTmp enck $ \tmp ->
|
retrieve h = fileRetriever $ \d k _p ->
|
||||||
sendAnnex k (void $ remove h enck) $ \src -> do
|
unlessM (runHook h "retrieve" k (Just d) $ return True) $
|
||||||
liftIO $ encrypt gpgOpts cipher (feedFile src) $
|
error "failed to retrieve content"
|
||||||
readBytes $ L.writeFile tmp
|
|
||||||
runHook h "store" enck (Just tmp) $ return True
|
|
||||||
|
|
||||||
retrieve :: HookName -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
|
|
||||||
retrieve h k _f d _p = runHook h "retrieve" k (Just d) $ return True
|
|
||||||
|
|
||||||
retrieveCheap :: HookName -> Key -> FilePath -> Annex Bool
|
retrieveCheap :: HookName -> Key -> FilePath -> Annex Bool
|
||||||
retrieveCheap _ _ _ = return False
|
retrieveCheap _ _ _ = return False
|
||||||
|
|
||||||
retrieveEncrypted :: HookName -> (Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool
|
|
||||||
retrieveEncrypted h (cipher, enck) _ f _p = withTmp enck $ \tmp ->
|
|
||||||
runHook h "retrieve" enck (Just tmp) $ liftIO $ catchBoolIO $ do
|
|
||||||
decrypt cipher (feedFile tmp) $
|
|
||||||
readBytes $ L.writeFile f
|
|
||||||
return True
|
|
||||||
|
|
||||||
remove :: HookName -> Key -> Annex Bool
|
remove :: HookName -> Key -> Annex Bool
|
||||||
remove h k = runHook h "remove" k Nothing $ return True
|
remove h k = runHook h "remove" k Nothing $ return True
|
||||||
|
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -1,7 +1,8 @@
|
||||||
git-annex (5.20140718) UNRELEASED; urgency=medium
|
git-annex (5.20140718) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* New chunk= option to chunk files stored in special remotes.
|
* New chunk= option to chunk files stored in special remotes.
|
||||||
Currently supported by: directory, S3, and all external special remotes.
|
Currently supported by: directory, S3, and all external and hook
|
||||||
|
special remotes.
|
||||||
* Partially transferred files are automatically resumed when using
|
* Partially transferred files are automatically resumed when using
|
||||||
chunked remotes!
|
chunked remotes!
|
||||||
* The old chunksize= option is deprecated. Do not use for new remotes.
|
* The old chunksize= option is deprecated. Do not use for new remotes.
|
||||||
|
|
|
@ -36,6 +36,8 @@ These parameters can be passed to `git annex initremote`:
|
||||||
|
|
||||||
* `keyid` - Specifies the gpg key to use for [[encryption]].
|
* `keyid` - Specifies the gpg key to use for [[encryption]].
|
||||||
|
|
||||||
|
* `chunk` - Enables [[chunking]] when storing large files.
|
||||||
|
|
||||||
## hooks
|
## hooks
|
||||||
|
|
||||||
Each type of hook remote is specified by a collection of hook commands.
|
Each type of hook remote is specified by a collection of hook commands.
|
||||||
|
|
Loading…
Reference in a new issue