( ctx context.Context, op string, path string, )
| 857 | } |
| 858 | |
| 859 | func (m *multiProtoFileModuleReadBucket[T, S]) getFileInfoAndDelegateIndex( |
| 860 | ctx context.Context, |
| 861 | op string, |
| 862 | path string, |
| 863 | ) (FileInfo, int, error) { |
| 864 | var fileInfos []FileInfo |
| 865 | var delegateIndexes []int |
| 866 | protoFileTracker := newProtoFileTracker() |
| 867 | for i, delegate := range m.delegates { |
| 868 | fileInfo, err := delegate.StatFileInfo(ctx, path) |
| 869 | if err != nil { |
| 870 | if errors.Is(err, fs.ErrNotExist) { |
| 871 | continue |
| 872 | } |
| 873 | return nil, 0, err |
| 874 | } |
| 875 | if fileInfo.FileType() != FileTypeProto { |
| 876 | continue |
| 877 | } |
| 878 | protoFileTracker.trackFileInfo(fileInfo) |
| 879 | fileInfos = append(fileInfos, fileInfo) |
| 880 | delegateIndexes = append(delegateIndexes, i) |
| 881 | } |
| 882 | // If we detected the same .proto file, this is an error. |
| 883 | if err := protoFileTracker.validate(); err != nil { |
| 884 | return nil, 0, err |
| 885 | } |
| 886 | switch len(fileInfos) { |
| 887 | case 0: |
| 888 | return nil, 0, &fs.PathError{Op: op, Path: path, Err: fs.ErrNotExist} |
| 889 | case 1: |
| 890 | return fileInfos[0], delegateIndexes[0], nil |
| 891 | default: |
| 892 | // If we detected a non-proto file duplicate, this means we constructed the multiProtoFileModuleReadBucket |
| 893 | // incorrectly, as we should not do union buckets for non-proto files. It is totally valid |
| 894 | // for LICENSE and README.md to be duplicated. |
| 895 | return nil, 0, newExistsMultipleModulesError(path, fileInfos...) |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | func (*multiProtoFileModuleReadBucket[T, S]) isModuleReadBucket() {} |
| 900 |
no test coverage detected