diff options
author | Joey Hess <joey@kitenet.net> | 2014-10-22 17:14:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-10-22 17:14:38 -0400 |
commit | 33e7dd2e0b756270cb51d1ed574cbe4b8173c7cd (patch) | |
tree | 0e9ff04c04c33cd1ba45171983d1b9f4d92cac60 /Remote/S3.hs | |
parent | 2d7b57270e628994483495159d2be715c8f9531b (diff) | |
parent | 49475bb89542e92c6f466425f29cd0640a8e80f4 (diff) |
Merge branch 'master' into s3-aws
Conflicts:
Remote/S3.hs
Diffstat (limited to 'Remote/S3.hs')
-rw-r--r-- | Remote/S3.hs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Remote/S3.hs b/Remote/S3.hs index 7c49937ce..fe0b4992a 100644 --- a/Remote/S3.hs +++ b/Remote/S3.hs @@ -5,9 +5,7 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE TypeFamilies #-} - -module Remote.S3 (remote, iaHost, configIA, isIAHost, iaItemUrl) where +module Remote.S3 (remote, iaHost, configIA, isIA, iaItemUrl) where import qualified Aws as AWS import qualified Aws.Core as AWS @@ -83,16 +81,21 @@ gen r u c gc = do readonly = False, availability = GloballyAvailable, remotetype = remote, - mkUnavailable = gen r u (M.insert "host" "!dne!" c) gc + mkUnavailable = gen r u (M.insert "host" "!dne!" c) gc, + getInfo = includeCredsInfo c (AWS.creds u) $ catMaybes + [ Just ("bucket", fromMaybe "unknown" (getBucket c)) + , if isIA c + then Just ("internet archive item", iaItemUrl $ fromMaybe "unknown" $ getBucket c) + else Nothing + ] } s3Setup :: Maybe UUID -> Maybe CredPair -> RemoteConfig -> Annex (RemoteConfig, UUID) s3Setup mu mcreds c = do u <- maybe (liftIO genUUID) return mu - c' <- setRemoteCredPair c (AWS.creds u) mcreds - s3Setup' u c' -s3Setup' :: UUID -> RemoteConfig -> Annex (RemoteConfig, UUID) -s3Setup' u c = if configIA c then archiveorg else defaulthost + s3Setup' u mcreds c +s3Setup' :: UUID -> Maybe CredPair -> RemoteConfig -> Annex (RemoteConfig, UUID) +s3Setup' u mcreds c = if isIA c then archiveorg else defaulthost where remotename = fromJust (M.lookup "name" c) defbucket = remotename ++ "-" ++ fromUUID u @@ -109,25 +112,27 @@ s3Setup' u c = if configIA c then archiveorg else defaulthost return (fullconfig, u) defaulthost = do - c' <- encryptionSetup c - let fullconfig = c' `M.union` defaults + (c', encsetup) <- encryptionSetup c + c'' <- setRemoteCredPair encsetup c' (AWS.creds u) mcreds + let fullconfig = c'' `M.union` defaults genBucket fullconfig u use fullconfig archiveorg = do showNote "Internet Archive mode" + c' <- setRemoteCredPair noEncryptionUsed c (AWS.creds u) mcreds -- Ensure user enters a valid bucket name, since -- this determines the name of the archive.org item. let validbucket = replace " " "-" $ map toLower $ fromMaybe (error "specify bucket=") $ - getBucketName c + getBucketName c' let archiveconfig = -- IA acdepts x-amz-* as an alias for x-archive-* M.mapKeys (replace "x-archive-" "x-amz-") $ -- encryption does not make sense here M.insert "encryption" "none" $ M.insert "bucket" validbucket $ - M.union c $ + M.union c' $ -- special constraints on key names M.insert "mungekeys" "ia" defaults info <- extractS3Info archiveconfig |