diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-16 16:35:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-16 16:35:47 -0400 |
commit | d264bca5daa81d7f9e39de6554ac51a0914ec4c0 (patch) | |
tree | 4d20ffc39e1bb8de0a2f34217d62593ebdba9f2c /Remote | |
parent | a58b4611211154ba6cd6f07c2914e89b2d036845 (diff) |
S3: Try to ensure bucket name is valid for archive.org.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/S3.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Remote/S3.hs b/Remote/S3.hs index e9c62eb25..348b240d4 100644 --- a/Remote/S3.hs +++ b/Remote/S3.hs @@ -102,23 +102,24 @@ s3Setup' u c = if isIA c then archiveorg else defaulthost archiveorg = do showNote "Internet Archive mode" - maybe (error "specify bucket=") (const noop) $ - getBucket archiveconfig - writeUUIDFile archiveconfig u - use archiveconfig - where - archiveconfig = + -- Ensure user enters a valid bucket name, since + -- this determines the name of the archive.org item. + let bucket = replace " " "-" $ map toLower $ + fromMaybe (error "specify bucket=") $ + getBucket c + let archiveconfig = -- hS3 does not pass through x-archive-* headers M.mapKeys (replace "x-archive-" "x-amz-") $ -- encryption does not make sense here M.insert "encryption" "none" $ + M.insert "bucket" bucket $ M.union c $ -- special constraints on key names M.insert "mungekeys" "ia" $ -- bucket created only when files are uploaded - M.insert "x-amz-auto-make-bucket" "1" $ - -- no default bucket name; should be human-readable - M.delete "bucket" defaults + M.insert "x-amz-auto-make-bucket" "1" defaults + writeUUIDFile archiveconfig u + use archiveconfig store :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store r k _f p = s3Action r False $ \(conn, bucket) -> |