From a89103be93e3cbe1b0269bbad7e67bba6a34db93 Mon Sep 17 00:00:00 2001 From: Brooklyn Zelenka Date: Mon, 31 Aug 2020 18:43:00 -0700 Subject: [PATCH] Set DNSLink *after* pinning (#396) --- fission-core/library/Fission/Types.hs | 72 +++++++++++++-------------- fission-core/package.yaml | 2 +- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/fission-core/library/Fission/Types.hs b/fission-core/library/Fission/Types.hs index 736e18884..02eb99c2d 100644 --- a/fission-core/library/Fission/Types.hs +++ b/fission-core/library/Fission/Types.hs @@ -448,25 +448,23 @@ instance User.Modifier Fission where return $ Error.openLeft err Right size -> do - _ <- runDB $ User.setDataDB userId newCID size now - - userDataDomain <- asks userRootDomain - zoneID <- asks userZoneID + IPFS.Pin.add newCID >>= \case + Left err -> + return $ Error.openLeft err - let - url = URL - { domainName = userDataDomain - , subdomain = Just $ Subdomain (username <> ".files") - } + Right _ -> do + zoneID <- asks userZoneID + userDataDomain <- asks userRootDomain - DNSLink.set userId url zoneID newCID >>= \case - Left err -> - return $ Error.relaxedLeft err + let + url = URL + { domainName = userDataDomain + , subdomain = Just $ Subdomain (username <> ".files") + } - Right _ -> - IPFS.Pin.add newCID >>= \case - Right _ -> return ok - Left err -> return $ Error.openLeft err + DNSLink.set userId url zoneID newCID >>= \case + Left err -> return $ Error.relaxedLeft err + Right _ -> Right <$> runDB (User.setDataDB userId newCID size now) instance User.Destroyer Fission where deactivate requestorId userId = runDB $ User.deactivate requestorId userId @@ -509,34 +507,32 @@ instance App.Modifier Fission where return $ Error.openLeft err Right size -> - runDB (App.setCidDB userId url newCID size copyFiles now) >>= \case + runDB (App.Domain.primarySibling userId url) >>= \case Left err -> - return $ Left err + return $ relaxedLeft err - Right appId -> do - runDB (App.Domain.primarySibling userId url) >>= \case + Right (Entity _ AppDomain {..}) -> + Domain.getByDomainName appDomainDomainName >>= \case Left err -> - return $ relaxedLeft err - - Right (Entity _ AppDomain {..}) -> - Domain.getByDomainName appDomainDomainName >>= \case + return $ openLeft err + + Right Domain {domainZoneId} -> do + result <- if copyFiles + then + IPFS.Pin.add newCID >>= \case + Right _ -> return ok + Left err -> return $ openLeft err + else + return ok + + case result of Left err -> - return $ openLeft err + return $ Left err - Right Domain {domainZoneId} -> + Right _ -> DNSLink.set userId (URL appDomainDomainName appDomainSubdomain) domainZoneId newCID >>= \case - Left err -> - return $ relaxedLeft err - - Right _ -> - if copyFiles - then - IPFS.Pin.add newCID <&> \case - Right _ -> Right appId - Left err -> Error.openLeft err - - else - return $ Right appId + Left err -> return $ relaxedLeft err + Right _ -> runDB (App.setCidDB userId url newCID size copyFiles now) instance App.Destroyer Fission where destroy uId appId now = diff --git a/fission-core/package.yaml b/fission-core/package.yaml index 128791cbf..3ecb6b288 100644 --- a/fission-core/package.yaml +++ b/fission-core/package.yaml @@ -1,5 +1,5 @@ name: fission-core -version: '2.8.0.1' +version: '2.8.1.0' category: API author: - Brooklyn Zelenka