MCPcopy Create free account
hub / github.com/JordanCoin/codemap / buildFileStubs

Function buildFileStubs

handoff/build.go:257–278  ·  view source on GitHub ↗
(root string, changed []changedEntry)

Source from the content-addressed store, hash-verified

255}
256
257func buildFileStubs(root string, changed []changedEntry) []FileStub {
258 if len(changed) == 0 {
259 return []FileStub{}
260 }
261
262 stubs := make([]FileStub, 0, len(changed))
263 for _, entry := range changed {
264 stub := FileStub{
265 Path: entry.Path,
266 Status: entry.Status,
267 }
268
269 absPath := filepath.Join(root, filepath.FromSlash(entry.Path))
270 info, err := os.Stat(absPath)
271 if err == nil && !info.IsDir() {
272 stub.Size = info.Size()
273 stub.Hash = fileSHA256(absPath)
274 }
275 stubs = append(stubs, stub)
276 }
277 return stubs
278}
279
280func fileSHA256(path string) string {
281 f, err := os.Open(path)

Callers 1

BuildFunction · 0.85

Calls 2

fileSHA256Function · 0.85
SizeMethod · 0.80

Tested by

no test coverage detected