fetchNarInfoStatusOnce fetches the cache status for the package and output. It returns a map of outputs to cache URIs for each cache hit. Missing outputs are not returned, and if no outputs are found, an nil map is returned. This function caches the result of the first call to avoid multiple calls
( outputName string, )
| 120 | // The outputName parameter is the name of the output to check for in the cache. |
| 121 | // If outputName is UseDefaultOutput, all default outputs will be checked. |
| 122 | func (p *Package) fetchNarInfoStatusOnce( |
| 123 | outputName string, |
| 124 | ) (map[string]string, error) { |
| 125 | ctx := context.TODO() |
| 126 | |
| 127 | outputToCache := map[string]string{} |
| 128 | caches, err := readCaches(ctx) |
| 129 | if err != nil { |
| 130 | return nil, err |
| 131 | } |
| 132 | |
| 133 | outputs, err := p.outputsForOutputName(outputName) |
| 134 | if err != nil { |
| 135 | return nil, err |
| 136 | } |
| 137 | |
| 138 | for _, output := range outputs { |
| 139 | pathParts := nix.NewStorePathParts(output.Path) |
| 140 | hash := pathParts.Hash |
| 141 | for _, cache := range caches { |
| 142 | inCache := false |
| 143 | if strings.HasPrefix(cache, "s3") { |
| 144 | inCache, err = fetchNarInfoStatusFromS3(ctx, cache, hash) |
| 145 | if err != nil { |
| 146 | return nil, err |
| 147 | } |
| 148 | } else { |
| 149 | inCache, err = fetchNarInfoStatusFromHTTP(ctx, cache, hash) |
| 150 | if err != nil { |
| 151 | return nil, err |
| 152 | } |
| 153 | } |
| 154 | if inCache { |
| 155 | // Found it, no need to check more caches. |
| 156 | outputToCache[output.Name] = cache |
| 157 | break |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | return outputToCache, nil |
| 163 | } |
| 164 | |
| 165 | func (p *Package) AreAllOutputsInCache( |
| 166 | ctx context.Context, w io.Writer, cacheURI string, |
no test coverage detected