This commit is contained in:
Mitchell Rosen 2022-04-12 21:52:50 -04:00
parent 30e8c8b4a4
commit 92971e2e7a

View File

@ -192,19 +192,19 @@ pull httpClient unisonShareUrl conn repoPath = do
Right Nothing -> pure (Right Nothing) Right Nothing -> pure (Right Nothing)
Right (Just hashJwt) -> do Right (Just hashJwt) -> do
let hash = Share.hashJWTHash hashJwt let hash = Share.hashJWTHash hashJwt
let success = pure (Right (Just (CausalHash (Hash.fromBase32Hex (Share.toBase32Hex hash)))))
runDB (entityLocation2 hash) >>= \case runDB (entityLocation2 hash) >>= \case
EntityInMainStorage2 -> success EntityInMainStorage2 -> pure ()
EntityInTempStorage2 missingDependencies -> do EntityInTempStorage2 missingDependencies -> doDownload missingDependencies
download httpClient unisonShareUrl conn (Share.RepoPath.repoName repoPath) missingDependencies EntityNotStored2 -> doDownload (NESet.singleton hashJwt)
success pure (Right (Just (CausalHash (Hash.fromBase32Hex (Share.toBase32Hex hash)))))
EntityNotStored2 -> do
download httpClient unisonShareUrl conn (Share.RepoPath.repoName repoPath) (NESet.singleton hashJwt)
success
where where
runDB :: ReaderT Connection IO a -> IO a runDB :: ReaderT Connection IO a -> IO a
runDB action = runReaderT action conn runDB action = runReaderT action conn
doDownload :: NESet Share.HashJWT -> IO ()
doDownload =
download httpClient unisonShareUrl conn (Share.RepoPath.repoName repoPath)
-- Download a set of entities from Unison Share. -- Download a set of entities from Unison Share.
download :: download ::
AuthorizedHttpClient -> AuthorizedHttpClient ->