From c2b98ba395aa486c18fa002175d93aa789b231d6 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 28 Aug 2023 21:05:47 +0200 Subject: Reimplement the info file printer --- app/SlackBuilder/Download.hs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'app/SlackBuilder/Download.hs') diff --git a/app/SlackBuilder/Download.hs b/app/SlackBuilder/Download.hs index c6516d4..2201c25 100644 --- a/app/SlackBuilder/Download.hs +++ b/app/SlackBuilder/Download.hs @@ -3,6 +3,7 @@ module SlackBuilder.Download , cloneAndArchive , commit , download + , downloadAndDeploy , hostedSources , remoteFileExists , updateSlackBuildVersion @@ -173,10 +174,11 @@ download uri target = traverse (runReq defaultHttpConfig . go . fst) clone :: Text -> Text -> Text -> SlackBuilderT (Maybe (Digest MD5)) clone repo tarball tagPrefix = do + repository' <- SlackBuilderT $ asks repository let tarballPath = Text.unpack tarball nameVersion = Text.pack $ takeBaseName tarballPath remotePath = Text.pack $ joinPath $ ("/" :) $ drop 1 $ splitPath tarballPath - localPath = "slackbuilds" tarballPath + localPath = repository' tarballPath remoteFileExists' <- remoteFileExists remotePath if remoteFileExists' @@ -187,3 +189,19 @@ clone repo tarball tagPrefix = do in cloneAndArchive repo nameVersion tarballPath tagPrefix >> uploadCommand tarball remotePath >> liftIO (runConduitRes go) <&> Just + +downloadAndDeploy :: Text -> Text -> SlackBuilderT (Maybe (Digest MD5)) +downloadAndDeploy uri tarball = do + repository' <- SlackBuilderT $ asks repository + let tarballPath = Text.unpack tarball + remotePath = Text.pack $ joinPath $ ("/" :) $ drop 1 $ splitPath tarballPath + localPath = repository' tarballPath + remoteFileExists' <- remoteFileExists remotePath + + if remoteFileExists' + then + hostedSources remotePath >>= flip download localPath + else do + checksum <- liftIO (mkURI uri) >>= flip download localPath + uploadCommand tarball remotePath + pure checksum -- cgit v1.2.3