(siteFS fs.FS)
| 477 | } |
| 478 | |
| 479 | func 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 | } |
no test coverage detected