about summary refs log tree commit diff stats
path: root/internal/fetcher/channel.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-20 23:55:40 +0200
committerAlan Pearce2024-05-20 23:55:40 +0200
commitb77a24f9f75378ffe97be83cf4dfd7f1683b9a7e (patch)
tree5e5efa81a76b8e3349c522729b98bb0d106f3bce /internal/fetcher/channel.go
parentc821da1cf55864852bcd8f337dd7acd0cc02f0b9 (diff)
downloadsearchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.tar.lz
searchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.tar.zst
searchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.zip
fix: make fetcher check on creation that it supports Source.Importer
Diffstat (limited to 'internal/fetcher/channel.go')
-rw-r--r--internal/fetcher/channel.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/fetcher/channel.go b/internal/fetcher/channel.go
index 5dc84b4..fd7427c 100644
--- a/internal/fetcher/channel.go
+++ b/internal/fetcher/channel.go
@@ -22,6 +22,23 @@ type ChannelFetcher struct {
 	Logger     *slog.Logger
 }
 
+func NewChannelFetcher(
+	source *config.Source,
+	dataPath string,
+	logger *slog.Logger,
+) (*ChannelFetcher, error) {
+	switch source.Importer {
+	case config.Options:
+		return &ChannelFetcher{
+			DataPath: dataPath,
+			Source:   source,
+			Logger:   logger,
+		}, nil
+	default:
+		return nil, fmt.Errorf("unsupported importer type %s", source.Importer)
+	}
+}
+
 func (i *ChannelFetcher) FetchIfNeeded(
 	parent context.Context,
 ) (f FetchedFiles, updated bool, err error) {
@@ -91,8 +108,7 @@ func (i *ChannelFetcher) FetchIfNeeded(
 	updated = before != after
 
 	f = FetchedFiles{
-		Options:  path.Join(dest, i.Source.OutputPath, "options.json"),
-		Packages: path.Join(dest, i.Source.OutputPath, "packages.json"),
+		Options: path.Join(dest, i.Source.OutputPath, "options.json"),
 	}
 
 	return