diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-08-28 21:05:47 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-08-28 21:05:47 +0200 |
| commit | c2b98ba395aa486c18fa002175d93aa789b231d6 (patch) | |
| tree | abd459165ae6c51f38358c65ed55a57efacab4c7 /app/SlackBuilder/Download.hs | |
| parent | 2126488066713719e26a1049adb080e68ec124f1 (diff) | |
| download | slackbuilder-c2b98ba395aa486c18fa002175d93aa789b231d6.tar.gz | |
Reimplement the info file printer
Diffstat (limited to 'app/SlackBuilder/Download.hs')
| -rw-r--r-- | app/SlackBuilder/Download.hs | 20 |
1 files changed, 19 insertions, 1 deletions
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 |
