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

Fix archive compression bug #373

Merged
merged 4 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit]: Can we remove the above comment while we're here? It was stale when we switched to using toString

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