From 16c70632242f00ac424601426575feb9ea523b75 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 5 Mar 2024 23:06:32 +0100 Subject: Make local paths relative to cwd --- lib/SlackBuilder/Download.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/SlackBuilder') diff --git a/lib/SlackBuilder/Download.hs b/lib/SlackBuilder/Download.hs index 719efe9..23ed3a4 100644 --- a/lib/SlackBuilder/Download.hs +++ b/lib/SlackBuilder/Download.hs @@ -142,16 +142,6 @@ remoteFileExists url = hostedSources url } go uri = req HEAD uri NoReqBody ignoreResponse mempty -uploadCommand :: FilePath -> Text -> SlackBuilderT () -uploadCommand localPath remotePath' = do - remoteRoot <- SlackBuilderT $ asks remotePath - localPathFromRepository <- relativeToRepository localPath - - liftIO $ callProcess "scp" - [ localPathFromRepository - , Text.unpack $ remoteRoot <> remotePath' - ] - cloneAndArchive :: Text -> FilePath -> Text -> SlackBuilderT () cloneAndArchive repo tarballPath tagPrefix = do let version = snd $ Text.breakOnEnd "-" @@ -217,6 +207,19 @@ cloneAndUpload repo tarballPath tagPrefix = do >> uploadCommand localPath remoteArchivePath >> liftIO (runConduitRes go) <&> (remoteResultURI,) +-- | Given a path to a local file and a remote path uploads the file using +-- the settings given in the configuration file. +-- +-- The remote path is given relative to the path in the configuration. +uploadCommand :: FilePath -> Text -> SlackBuilderT () +uploadCommand localPath remotePath' = do + remoteRoot <- SlackBuilderT $ asks remotePath + + liftIO $ callProcess "scp" + [ localPath + , Text.unpack $ remoteRoot <> remotePath' + ] + -- | Downlaods a file into the directory. Returns name of the downloaded file -- and checksum. -- -- cgit v1.2.3