aboutsummaryrefslogtreecommitdiff
path: root/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-08-29 13:00:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-08-29 13:00:41 -0400
commitffcea3cdab00f2d2f5e8352ee1a97a71c684e626 (patch)
tree1f6f140e5f62a6e675618a120e5a157dba2fe1ee /Types
parent6256956f4f334b2fe7318f91b6ce86c9a4192c00 (diff)
add API for exporting
Implemented so far for the directory special remote. Several remotes don't make sense to export to. Regular Git remotes, obviously, do not. Bup remotes almost certianly do not, since bup would need to be used to extract the export; same store for Ddar. Web and Bittorrent are download-only. GCrypt is always encrypted so exporting to it would be pointless. There's probably no point complicating the Hook remotes with exporting at this point. External, S3, Glacier, WebDAV, Rsync, and possibly Tahoe should be modified to support export. Thought about trying to reuse the storeKey/retrieveKeyFile/removeKey interface, rather than adding a new interface. But, it seemed better to keep it separate, to avoid a complicated interface that sometimes encrypts/chunks key/value storage and sometimes users non-key/value storage. Any common parts can be factored out. Note that storeExport is not atomic. doc/design/exporting_trees_to_special_remotes.mdwn has some things in the "resuming exports" section that bear on this decision. Basically, I don't think, at this time, that an atomic storeExport would help with resuming, because exports are not key/value storage, and we can't be sure that a partially uploaded file is the same content we're currently trying to export. Also, note that ExportLocation will always use unix path separators. This is important, because users may export from a mix of windows and unix, and it avoids complicating the API with path conversions, and ensures that in such a mix, they always use the same locations for exports. This commit was sponsored by Bruno BEAUFILS on Patreon.
Diffstat (limited to 'Types')
-rw-r--r--Types/Remote.hs26
1 files changed, 25 insertions, 1 deletions
diff --git a/Types/Remote.hs b/Types/Remote.hs
index bd75840b3..d4b76f54f 100644
--- a/Types/Remote.hs
+++ b/Types/Remote.hs
@@ -2,7 +2,7 @@
-
- Most things should not need this, using Types instead
-
- - Copyright 2011-2014 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -18,6 +18,7 @@ module Types.Remote
, Availability(..)
, Verification(..)
, unVerified
+ , ExportLocation(..)
)
where
@@ -69,6 +70,7 @@ data RemoteA a = Remote {
name :: RemoteName,
-- Remotes have a use cost; higher is more expensive
cost :: Cost,
+
-- Transfers a key's contents from disk to the remote.
-- The key should not appear to be present on the remote until
-- all of its contents have been transferred.
@@ -94,6 +96,23 @@ data RemoteA a = Remote {
-- Some remotes can checkPresent without an expensive network
-- operation.
checkPresentCheap :: Bool,
+
+ -- Exports a key's contents to an ExportLocation.
+ -- The exported file does not need to be updated atomically.
+ storeExport :: Maybe (Key -> ExportLocation -> MeterUpdate -> a Bool),
+ -- Retrieves an exported key to a file.
+ -- (The MeterUpdate does not need to be used if it writes
+ -- sequentially to the file.)
+ retrieveExport :: Maybe (Key -> ExportLocation -> FilePath -> MeterUpdate -> a (Bool, Verification)),
+ -- Removes an exported key (succeeds if the contents are not present)
+ removeExport :: Maybe (Key -> ExportLocation -> a Bool),
+ -- Checks if a key is exported to the remote at the specified
+ -- ExportLocation.
+ -- Throws an exception if the remote cannot be accessed.
+ checkPresentExport :: Maybe (Key -> ExportLocation -> a Bool),
+ -- Renames an already exported key.
+ renameExport :: Maybe (Key -> ExportLocation -> ExportLocation -> a Bool),
+
-- Some remotes can provide additional details for whereis.
whereisKey :: Maybe (Key -> a [String]),
-- Some remotes can run a fsck operation on the remote,
@@ -150,3 +169,8 @@ unVerified :: Monad m => m Bool -> m (Bool, Verification)
unVerified a = do
ok <- a
return (ok, UnVerified)
+
+-- A location on a remote that a key can be exported to.
+-- The FilePath will be relative, and may contain unix-style path
+-- separators.
+newtype ExportLocation = ExportLocation FilePath