Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
Fix archive compression bug (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck authored Sep 17, 2021
1 parent 0846790 commit 45f6917
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Spectrometer Changelog

## v2.15.19

- Fixes an issue with `fossa-deps.yml` `vendored-dependencies` entries where uploads would fail if the dependency was in a subdirectory. ([#373](https://github.com/fossas/spectrometer/pull/373))

## v2.15.18

- Monorepo: Speeds up commercial phrase detection by doing a first pass before trying to parse context. ([#371](https://github.com/fossas/spectrometer/issues/371))
Expand Down
8 changes: 5 additions & 3 deletions src/App/Fossa/ArchiveUploader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Data.Aeson (
import Data.Aeson.Extra
import Data.ByteString.Lazy qualified as BS
import Data.Functor.Extra ((<$$>))
import Data.List (intercalate)
import Data.Maybe (fromMaybe)
import Data.String.Conversion
import Data.Text (Text)
Expand Down Expand Up @@ -96,9 +97,7 @@ arcToLocator arc =

compressFile :: Path Abs Dir -> Path Abs Dir -> FilePath -> IO FilePath
compressFile outputDir directory fileToTar = do
-- Without using `fromAbsDir` for each of these directories, the conversion
-- is incorrect. `show outputDir` gives an incorrect result even though it typechecks.
let finalFile = toString outputDir </> fileToTar
let finalFile = toString outputDir </> safeSeparators fileToTar
entries <- Tar.pack (toString directory) [fileToTar]
BS.writeFile finalFile $ GZip.compress $ Tar.write entries
pure finalFile
Expand All @@ -110,3 +109,6 @@ hashFile :: FilePath -> IO Text
hashFile fileToHash = do
fileContent <- BS.readFile fileToHash
pure . toText . show $ md5 fileContent

safeSeparators :: FilePath -> FilePath
safeSeparators = intercalate "_" . splitDirectories

0 comments on commit 45f6917

Please sign in to comment.