(root string, changed []changedEntry)
| 255 | } |
| 256 | |
| 257 | func 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 | |
| 280 | func fileSHA256(path string) string { |
| 281 | f, err := os.Open(path) |
no test coverage detected