(ctx context.Context, rep repo.Repository, ms []*snapshot.Manifest, path string, filter func(*snapshot.Manifest, int, int) bool)
| 637 | } |
| 638 | |
| 639 | func findLastManifestWithPath(ctx context.Context, rep repo.Repository, ms []*snapshot.Manifest, path string, filter func(*snapshot.Manifest, int, int) bool) (*snapshot.Manifest, string, object.ID) { |
| 640 | ms = snapshot.SortByTime(ms, true) |
| 641 | |
| 642 | type candidateInfo struct { |
| 643 | m *snapshot.Manifest |
| 644 | pe []string |
| 645 | ohid object.HasObjectID |
| 646 | } |
| 647 | |
| 648 | var candidates []candidateInfo |
| 649 | |
| 650 | for _, m := range ms { |
| 651 | if m.IncompleteReason != "" { |
| 652 | // Ignore this snapshot |
| 653 | continue |
| 654 | } |
| 655 | |
| 656 | root, err := snapshotfs.SnapshotRoot(rep, m) |
| 657 | if err != nil { |
| 658 | // Ignore this snapshot |
| 659 | continue |
| 660 | } |
| 661 | |
| 662 | pathElements, err := findRelativePathParts(m, path) |
| 663 | if err != nil { |
| 664 | // Ignore this snapshot |
| 665 | continue |
| 666 | } |
| 667 | |
| 668 | ent, err := snapshotfs.GetNestedEntry(ctx, root, pathElements) |
| 669 | if err != nil { |
| 670 | // Ignore this snapshot |
| 671 | continue |
| 672 | } |
| 673 | |
| 674 | ohid, ok := ent.(object.HasObjectID) |
| 675 | if !ok { |
| 676 | // Ignore this snapshot |
| 677 | continue |
| 678 | } |
| 679 | |
| 680 | candidates = append(candidates, candidateInfo{m, pathElements, ohid}) |
| 681 | } |
| 682 | |
| 683 | for i, c := range candidates { |
| 684 | if !filter(c.m, i, len(candidates)) { |
| 685 | // Ignore this snapshot |
| 686 | continue |
| 687 | } |
| 688 | |
| 689 | return c.m, filepath.Join(c.pe...), c.ohid.ObjectID() |
| 690 | } |
| 691 | |
| 692 | return nil, "", object.ID{} |
| 693 | } |
no test coverage detected