summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Gpg.hs21
-rw-r--r--Storage.hs2
-rw-r--r--Storage/LocalFiles.hs2
3 files changed, 23 insertions, 2 deletions
diff --git a/Gpg.hs b/Gpg.hs
new file mode 100644
index 0000000..bf4cbe6
--- /dev/null
+++ b/Gpg.hs
@@ -0,0 +1,21 @@
+{- Copyright 2016 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU AGPL version 3 or higher.
+ -}
+
+module Gpg where
+
+import Types
+import System.Process
+
+-- | Converts an input KeyId, which can be short, or even a name or email,
+-- to a long-form gpg KeyId of a secret key.
+getFullKeyId :: KeyId -> IO (Maybe KeyId)
+-- gpg --batch --with-colons --list-secret-keys
+-- extract from eg, sec::4096:1:C910D9222512E3C7:...
+
+-- | Check if a given gpg key is present on the keyserver.
+-- (Without downloading the key.)
+knownByKeyServer :: KeyId -> IO Bool
+-- gpg --batch --with-colons --search-keys 2>/dev/null
+-- check if output includes pub: line
diff --git a/Storage.hs b/Storage.hs
index cb0e323..d13cbfe 100644
--- a/Storage.hs
+++ b/Storage.hs
@@ -16,7 +16,7 @@ data Storage = Storage
, countShards :: IO CountResult
} -- Note that there is no interface to enumerate shards.
-data StoreResult = StoreSuccess | StoreFailure String
+data StoreResult = StoreSuccess | StoreAlreadyExists | StoreFailure String
deriving (Show)
data RetrieveResult = RetrieveSuccess Shard | RetrieveFailure String
diff --git a/Storage/LocalFiles.hs b/Storage/LocalFiles.hs
index f34a8b5..ebcc492 100644
--- a/Storage/LocalFiles.hs
+++ b/Storage/LocalFiles.hs
@@ -38,7 +38,7 @@ store i s = onError (StoreFailure . show) $ do
let dest = dir </> shardFile i
exists <- doesFileExist dest
if exists
- then return $ StoreFailure "file already exists"
+ then return StoreAlreadyExists
else do
let tmp = dest ++ ".tmp"
fd <- openFd tmp WriteOnly (Just 0o666)