Skip to content

Commit

Permalink
Seperate generic version of getBucketContents
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Oct 5, 2012
1 parent dc46802 commit c0d3ea0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Network/Aliyun.hs
Expand Up @@ -5,6 +5,7 @@
, TypeFamilies
, TupleSections
, FlexibleContexts
, Rank2Types
#-}
module Network.Aliyun
( Yun(..)
Expand All @@ -17,6 +18,7 @@ module Network.Aliyun
, putBucket
, getBucket
, getBucketContents
, getBucketContentsLifted
, getBucketACL
, deleteBucket
, putObject
Expand Down Expand Up @@ -160,16 +162,19 @@ getBucket name qry =
, maybe "" (("&delimiter="++) . T.singleton) (qryDelimiter qry)
]

getBucketContents :: MonadBase Yun m => ByteString -> BucketQuery -> C.Source m BucketContent
getBucketContents name query = loop query
getBucketContentsLifted :: Monad m => (forall a. Yun a -> m a) -> ByteString -> BucketQuery -> C.Source m BucketContent
getBucketContentsLifted liftYun name query = loop query
where
loop qry = do
bucket <- lift $ liftBase $ getBucket name qry
bucket <- lift $ liftYun $ getBucket name qry
mapM_ (C.yield . ContentDirectory) (bucketDirectories bucket)
mapM_ (C.yield . ContentFile) (bucketContents bucket)
when (bucketIsTruncated bucket) $
loop qry{qryMarker=bucketNextMarker bucket}

getBucketContents :: ByteString -> BucketQuery -> C.Source Yun BucketContent
getBucketContents = getBucketContentsLifted id

getBucketACL :: ByteString -> Yun BucketACL
getBucketACL name =
xmlResponse =<< lbsRequest def{ hPath = S.concat ["/", name, "?acl"] }
Expand Down

0 comments on commit c0d3ea0

Please sign in to comment.