MCPcopy Index your code
hub / github.com/coder/coder / parseSHA1

Function parseSHA1

site/bin.go:479–498  ·  view source on GitHub ↗
(siteFS fs.FS)

Source from the content-addressed store, hash-verified

477}
478
479func parseSHA1(siteFS fs.FS) (map[string]string, error) {
480 b, err := fs.ReadFile(siteFS, "bin/coder.sha1")
481 if err != nil {
482 return nil, xerrors.Errorf("read coder sha1 from embedded fs failed: %w", err)
483 }
484
485 shaFiles := make(map[string]string)
486 for _, line := range bytes.Split(bytes.TrimSpace(b), []byte{'\n'}) {
487 parts := bytes.Split(line, []byte{' ', '*'})
488 if len(parts) != 2 {
489 return nil, xerrors.Errorf("malformed sha1 file: %w", err)
490 }
491 shaFiles[string(parts[1])] = strings.ToLower(string(parts[0]))
492 }
493 if len(shaFiles) == 0 {
494 return nil, xerrors.Errorf("empty sha1 file: %w", err)
495 }
496
497 return shaFiles, nil
498}

Callers 1

ExtractOrReadBinFSFunction · 0.85

Calls 2

ReadFileMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected