MCPcopy Create free account
hub / github.com/bufbuild/buf / addPath

Method addPath

private/bufpkg/bufimage/module_file_resolver.go:145–180  ·  view source on GitHub ↗
(
	path string,
	externalPath string,
	localPath string,
	moduleFullName bufparse.FullName,
	commitID uuid.UUID,
)

Source from the content-addressed store, hash-verified

143}
144
145func (m *moduleFileResolver) addPath(
146 path string,
147 externalPath string,
148 localPath string,
149 moduleFullName bufparse.FullName,
150 commitID uuid.UUID,
151) error {
152 m.lock.Lock()
153 defer m.lock.Unlock()
154 existingExternalPath, ok := m.pathToExternalPath[path]
155 if ok {
156 if existingExternalPath != externalPath {
157 return fmt.Errorf("had external paths %q and %q for path %q", existingExternalPath, externalPath, path)
158 }
159 } else {
160 m.pathToExternalPath[path] = externalPath
161 }
162 if localPath != "" {
163 existingLocalPath, ok := m.pathToLocalPath[path]
164 if ok {
165 if existingLocalPath != localPath {
166 return fmt.Errorf("had local paths %q and %q for path %q", existingLocalPath, localPath, path)
167 }
168 } else {
169 m.pathToLocalPath[path] = localPath
170 m.localPathToPath[localPath] = path
171 }
172 }
173 if moduleFullName != nil {
174 m.pathToFullName[path] = moduleFullName
175 }
176 if commitID != uuid.Nil {
177 m.pathToCommitID[path] = commitID
178 }
179 return nil
180}
181
182// readObjectCloserToSourceFile is a helper function that takes a given [storage.ReadObjectCloser]
183// and returns the corresponding [*source.File].

Callers 1

OpenMethod · 0.95

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected