all repos — searchix @ a49d405f81ed9b872ae638832f3a1a5f2339780c

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: make downloaded filenames consistent

Alan Pearce
commit

a49d405f81ed9b872ae638832f3a1a5f2339780c

parent

cee12761d4ab83d717452e22a34708161f722b1f

1 file changed, 9 insertions(+), 10 deletions(-)

changed files
M internal/fetcher/nixpkgs-channel.gointernal/fetcher/nixpkgs-channel.go
@@ -3,7 +3,6 @@
import ( "context" "net/url" - "strings" "alin.ovh/searchix/internal/config" "alin.ovh/searchix/internal/fetcher/http"
@@ -51,13 +50,13 @@ sourceMeta *index.SourceMeta,
) (f *FetchedFiles, err error) { f = &FetchedFiles{} - filesToFetch := make([]string, 2) - filesToFetch[0] = revisionFilename + filesToFetch := make(map[string]string, 2) + filesToFetch[revisionFilename] = "revision" switch i.Source.Importer { case config.Packages: - filesToFetch[1] = packagesFileName + filesToFetch[packagesFileName] = "packages.json" case config.Options: - filesToFetch[1] = optionsFilename + filesToFetch[optionsFilename] = "options.json" } fetcher := http.NewFetcher(&http.Options{
@@ -66,9 +65,9 @@ Root: i.Root,
}) var fetchURL string - for _, filename := range filesToFetch { - target := i.Source.JoinPath(strings.TrimSuffix(filename, ".br")) - fetchURL, err = makeChannelURL(i.Source.Channel, filename) + for urlname, filename := range filesToFetch { + target := i.Source.JoinPath(filename) + fetchURL, err = makeChannelURL(i.Source.Channel, urlname) if err != nil { return }
@@ -85,7 +84,7 @@ return nil, fault.Wrap(err, fmsg.Withf("could not stat file %s", target))
} sourceMeta.Updated = stat.ModTime() - switch filename { + switch urlname { case revisionFilename: f.Revision = body case optionsFilename:
@@ -93,7 +92,7 @@ f.Options = body
case packagesFileName: f.Packages = body default: - return f, fault.Newf("unknown file kind %s", filename) + return f, fault.Newf("unknown file kind %s", urlname) } }