( ctx context.Context, fn func(FileInfo) error, options ...WalkFileInfosOption, )
| 804 | } |
| 805 | |
| 806 | func (m *multiProtoFileModuleReadBucket[T, S]) WalkFileInfos( |
| 807 | ctx context.Context, |
| 808 | fn func(FileInfo) error, |
| 809 | options ...WalkFileInfosOption, |
| 810 | ) error { |
| 811 | seenPathToFileInfo := make(map[string]FileInfo) |
| 812 | protoFileTracker := newProtoFileTracker() |
| 813 | for _, delegate := range m.delegates { |
| 814 | if err := delegate.WalkFileInfos( |
| 815 | ctx, |
| 816 | func(fileInfo FileInfo) error { |
| 817 | if fileInfo.FileType() != FileTypeProto { |
| 818 | return nil |
| 819 | } |
| 820 | path := fileInfo.Path() |
| 821 | protoFileTracker.trackFileInfo(fileInfo) |
| 822 | if existingFileInfo, ok := seenPathToFileInfo[path]; ok { |
| 823 | // If we detected the same .proto file, this is an error. |
| 824 | if err := protoFileTracker.validate(); err != nil { |
| 825 | return err |
| 826 | } |
| 827 | // If we detected a non-proto file duplicate, this means we constructed the multiProtoFileModuleReadBucket |
| 828 | // incorrectly, as we should not do union buckets for non-proto files. It is totally valid |
| 829 | // for LICENSE and README.md to be duplicated. |
| 830 | // |
| 831 | // This does not return all paths that are matching, unlike GetFile and StatFileInfo. |
| 832 | // We do not want to continue iterating, as calling WalkFileInfos on the same path |
| 833 | // could cause errors downstream as callers expect a single call per path. |
| 834 | return newExistsMultipleModulesError(path, existingFileInfo, fileInfo) |
| 835 | } |
| 836 | seenPathToFileInfo[path] = fileInfo |
| 837 | return fn(fileInfo) |
| 838 | }, |
| 839 | options..., |
| 840 | ); err != nil { |
| 841 | return err |
| 842 | } |
| 843 | } |
| 844 | return nil |
| 845 | } |
| 846 | |
| 847 | func (m *multiProtoFileModuleReadBucket[T, S]) ShouldBeSelfContained() bool { |
| 848 | return m.shouldBeSelfContained |
nothing calls this directly
no test coverage detected