Skip to content

Commit

Permalink
Set DNSLink *after* pinning (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
expede authored Sep 1, 2020
1 parent a71ae79 commit a89103b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 39 deletions.
72 changes: 34 additions & 38 deletions fission-core/library/Fission/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion fission-core/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fission-core
version: '2.8.0.1'
version: '2.8.1.0'
category: API
author:
- Brooklyn Zelenka
Expand Down

0 comments on commit a89103b

Please sign in to comment.