S3: Fix url construction bug

When the publicurl has been set to an url that does not end with a slash,
we need to add one in between it and the rest of the url.

As far as I can see, git-annex does not default to such publicurls; it's
careful to end them with slashes. But this was observed in the wild, and
there may be documentation that doesn't include the slash. And it's an easy
mistake to make in any case.

This commit was sponsored by Eric Drechsel on Patreon.
This commit is contained in:
Joey Hess 2018-09-14 12:25:23 -04:00
parent 858f140ab0
commit 773084c49b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,10 @@
git-annex (6.20180914) UNRELEASED; urgency=medium
* S3: Fix url construction bug when the publicurl has been set to an url
that does not end with a slash.
-- Joey Hess <id@joeyh.name> Fri, 14 Sep 2018 12:20:19 -0400
git-annex (6.20180913) upstream; urgency=medium
* When --batch is used with matching options like --in, --metadata,

View file

@ -21,6 +21,7 @@ import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString as BS
import qualified Data.Map as M
import qualified Data.Set as S
import qualified System.FilePath.Posix as Posix
import Data.Char
import Network.Socket (HostName)
import Network.HTTP.Conduit (Manager)
@ -690,7 +691,7 @@ awsPublicUrl info = genericPublicUrl $
"https://" ++ T.unpack (bucket info) ++ ".s3.amazonaws.com/"
genericPublicUrl :: URLString -> BucketObject -> URLString
genericPublicUrl baseurl p = baseurl ++ p
genericPublicUrl baseurl p = baseurl Posix.</> p
genCredentials :: CredPair -> IO AWS.Credentials
genCredentials (keyid, secret) = AWS.Credentials