rename isIA to configIA
Already done on s3-aws branch, so reduce divergence.
This commit is contained in:
parent
a1fb1b7ae3
commit
fa1318479e
4 changed files with 11 additions and 11 deletions
|
@ -162,7 +162,7 @@ getEnableS3R :: UUID -> Handler Html
|
||||||
#ifdef WITH_S3
|
#ifdef WITH_S3
|
||||||
getEnableS3R uuid = do
|
getEnableS3R uuid = do
|
||||||
m <- liftAnnex readRemoteLog
|
m <- liftAnnex readRemoteLog
|
||||||
if maybe False S3.isIA (M.lookup uuid m)
|
if maybe False S3.confgiIA (M.lookup uuid m)
|
||||||
then redirect $ EnableIAR uuid
|
then redirect $ EnableIAR uuid
|
||||||
else postEnableS3R uuid
|
else postEnableS3R uuid
|
||||||
#else
|
#else
|
||||||
|
@ -224,5 +224,5 @@ previouslyUsedAWSCreds :: Annex (Maybe CredPair)
|
||||||
previouslyUsedAWSCreds = getM gettype [S3.remote, Glacier.remote]
|
previouslyUsedAWSCreds = getM gettype [S3.remote, Glacier.remote]
|
||||||
where
|
where
|
||||||
gettype t = previouslyUsedCredPair AWS.creds t $
|
gettype t = previouslyUsedCredPair AWS.creds t $
|
||||||
not . S3.isIA . Remote.config
|
not . S3.configIA . Remote.config
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -239,7 +239,7 @@ getRepoInfo :: Maybe Remote.Remote -> Maybe Remote.RemoteConfig -> Widget
|
||||||
getRepoInfo (Just r) (Just c) = case M.lookup "type" c of
|
getRepoInfo (Just r) (Just c) = case M.lookup "type" c of
|
||||||
Just "S3"
|
Just "S3"
|
||||||
#ifdef WITH_S3
|
#ifdef WITH_S3
|
||||||
| S3.isIA c -> IA.getRepoInfo c
|
| S3.configIA c -> IA.getRepoInfo c
|
||||||
#endif
|
#endif
|
||||||
| otherwise -> AWS.getRepoInfo c
|
| otherwise -> AWS.getRepoInfo c
|
||||||
Just t
|
Just t
|
||||||
|
|
|
@ -107,7 +107,7 @@ iaCredsAForm defcreds = AWS.AWSCreds
|
||||||
#ifdef WITH_S3
|
#ifdef WITH_S3
|
||||||
previouslyUsedIACreds :: Annex (Maybe CredPair)
|
previouslyUsedIACreds :: Annex (Maybe CredPair)
|
||||||
previouslyUsedIACreds = previouslyUsedCredPair AWS.creds S3.remote $
|
previouslyUsedIACreds = previouslyUsedCredPair AWS.creds S3.remote $
|
||||||
S3.isIA . Remote.config
|
S3.configIA . Remote.config
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
accessKeyIDFieldWithHelp :: Maybe Text -> MkAForm Text
|
accessKeyIDFieldWithHelp :: Maybe Text -> MkAForm Text
|
||||||
|
|
14
Remote/S3.hs
14
Remote/S3.hs
|
@ -5,7 +5,7 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Remote.S3 (remote, iaHost, isIA, iaItemUrl) where
|
module Remote.S3 (remote, iaHost, configIA, iaItemUrl) where
|
||||||
|
|
||||||
import Network.AWS.AWSConnection
|
import Network.AWS.AWSConnection
|
||||||
import Network.AWS.S3Object hiding (getStorageClass)
|
import Network.AWS.S3Object hiding (getStorageClass)
|
||||||
|
@ -74,7 +74,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
|
||||||
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
|
getInfo = includeCredsInfo c (AWS.creds u) $ catMaybes
|
||||||
[ Just ("bucket", fromMaybe "unknown" (getBucket c))
|
[ Just ("bucket", fromMaybe "unknown" (getBucket c))
|
||||||
, if isIA c
|
, if configIA c
|
||||||
then Just ("internet archive item", iaItemUrl $ fromMaybe "unknown" $ getBucket c)
|
then Just ("internet archive item", iaItemUrl $ fromMaybe "unknown" $ getBucket c)
|
||||||
else Nothing
|
else Nothing
|
||||||
]
|
]
|
||||||
|
@ -85,7 +85,7 @@ s3Setup mu mcreds c = do
|
||||||
u <- maybe (liftIO genUUID) return mu
|
u <- maybe (liftIO genUUID) return mu
|
||||||
s3Setup' u mcreds c
|
s3Setup' u mcreds c
|
||||||
s3Setup' :: UUID -> Maybe CredPair -> RemoteConfig -> Annex (RemoteConfig, UUID)
|
s3Setup' :: UUID -> Maybe CredPair -> RemoteConfig -> Annex (RemoteConfig, UUID)
|
||||||
s3Setup' u mcreds c = if isIA c then archiveorg else defaulthost
|
s3Setup' u mcreds c = if configIA c then archiveorg else defaulthost
|
||||||
where
|
where
|
||||||
remotename = fromJust (M.lookup "name" c)
|
remotename = fromJust (M.lookup "name" c)
|
||||||
defbucket = remotename ++ "-" ++ fromUUID u
|
defbucket = remotename ++ "-" ++ fromUUID u
|
||||||
|
@ -136,7 +136,7 @@ prepareStore r = resourcePrepare (const $ s3Action r False) $ \(conn, bucket) ->
|
||||||
ok <- s3Bool =<< liftIO (store (conn, bucket) r k p src)
|
ok <- s3Bool =<< liftIO (store (conn, bucket) r k p src)
|
||||||
|
|
||||||
-- Store public URL to item in Internet Archive.
|
-- Store public URL to item in Internet Archive.
|
||||||
when (ok && isIA (config r) && not (isChunkKey k)) $
|
when (ok && configIA (config r) && not (isChunkKey k)) $
|
||||||
setUrlPresent k (iaKeyUrl r k)
|
setUrlPresent k (iaKeyUrl r k)
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
|
@ -168,7 +168,7 @@ retrieveCheap _ _ = return False
|
||||||
- derived from it that it does not remove. -}
|
- derived from it that it does not remove. -}
|
||||||
remove :: Remote -> RemoteConfig -> Remover
|
remove :: Remote -> RemoteConfig -> Remover
|
||||||
remove r c k
|
remove r c k
|
||||||
| isIA c = do
|
| configIA c = do
|
||||||
warning "Cannot remove content from the Internet Archive"
|
warning "Cannot remove content from the Internet Archive"
|
||||||
return False
|
return False
|
||||||
| otherwise = remove' r k
|
| otherwise = remove' r k
|
||||||
|
@ -336,8 +336,8 @@ getXheaders = filter isxheader . M.assocs
|
||||||
iaHost :: HostName
|
iaHost :: HostName
|
||||||
iaHost = "s3.us.archive.org"
|
iaHost = "s3.us.archive.org"
|
||||||
|
|
||||||
isIA :: RemoteConfig -> Bool
|
configIA :: RemoteConfig -> Bool
|
||||||
isIA c = maybe False isIAHost (M.lookup "host" c)
|
configIA c = maybe False isIAHost (M.lookup "host" c)
|
||||||
|
|
||||||
isIAHost :: HostName -> Bool
|
isIAHost :: HostName -> Bool
|
||||||
isIAHost h = ".archive.org" `isSuffixOf` map toLower h
|
isIAHost h = ".archive.org" `isSuffixOf` map toLower h
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue