diff options
author | Alan Pearce | 2024-05-17 10:51:42 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-17 12:21:19 +0200 |
commit | b8da487f774aa2399b79bbde5f2e6e13be4fce1c (patch) | |
tree | ff3379ea1ac598a025f7e70ccc6c7fc3d0b44434 /internal/importer/package.go | |
parent | 27b07a80f1872205dfeb949e9b90cf85f6e43744 (diff) | |
download | searchix-b8da487f774aa2399b79bbde5f2e6e13be4fce1c.tar.lz searchix-b8da487f774aa2399b79bbde5f2e6e13be4fce1c.tar.zst searchix-b8da487f774aa2399b79bbde5f2e6e13be4fce1c.zip |
feat: decode brotli-compressed files
Diffstat (limited to 'internal/importer/package.go')
-rw-r--r-- | internal/importer/package.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/internal/importer/package.go b/internal/importer/package.go index 3e0ec83..a1a6c67 100644 --- a/internal/importer/package.go +++ b/internal/importer/package.go @@ -3,8 +3,8 @@ package importer import ( "context" "encoding/json" + "io" "log/slog" - "os" "reflect" "searchix/internal/config" "searchix/internal/nix" @@ -41,7 +41,7 @@ type PackageIngester struct { dec *jstream.Decoder ms *mapstructure.Decoder pkg *packageJSON - infile *os.File + infile io.ReadCloser source *config.Source } @@ -60,11 +60,7 @@ func makeAdhocPlatform(v any) string { return string(s) } -func NewPackageProcessor(inpath string, source *config.Source) (*PackageIngester, error) { - infile, err := os.Open(inpath) - if err != nil { - return nil, errors.WithMessagef(err, "failed to open input file %s", inpath) - } +func NewPackageProcessor(infile io.ReadCloser, source *config.Source) (*PackageIngester, error) { i := &PackageIngester{ dec: jstream.NewDecoder(infile, 2).EmitKV(), pkg: &packageJSON{}, |