From b176c38dbe063f11e995566b5af050094f44593f Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 17 Jun 2014 13:07:01 +0300 Subject: [PATCH] Detect missing S3 objects #6 --- Data/BlobStore.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Data/BlobStore.hs b/Data/BlobStore.hs index b2cc006..51d8516 100644 --- a/Data/BlobStore.hs +++ b/Data/BlobStore.hs @@ -137,7 +137,7 @@ cachedS3Store cache creds bucket prefix manager = case msrc of Just src -> return $ Just src Nothing -> do - liftIO $ runResourceT $ do + join $ liftIO $ handle (\S3Error{} -> return $ return Nothing) $ runResourceT $ do res <- Aws.aws (Aws.Configuration Aws.Timestamp creds $ Aws.defaultLog Aws.Error) @@ -146,6 +146,7 @@ cachedS3Store cache creds bucket prefix manager = (Aws.getObject bucket (toS3Path key)) gor <- Aws.readResponseIO res let fp = toFP cache key + liftIO $ F.createTree $ directory fp bracketOnError (liftIO $ IO.openBinaryTempFile (fpToString $ directory fp) @@ -158,7 +159,7 @@ cachedS3Store cache creds bucket prefix manager = liftIO $ do hClose h F.rename (fpFromString fpTmp) fp - storeRead' (fileStore cache) key -- FIXME optimize? + return $ storeRead' (fileStore cache) key -- FIXME optimize? else storeRead' (fileStore cache) key , storeExists' = \key -> if shouldBackup key