(db *sql.DB, inode uint64)
| 288 | } |
| 289 | |
| 290 | func getAllBlocks(db *sql.DB, inode uint64) ([]byte, error) { |
| 291 | blocks, err := getBlocks(db, inode) |
| 292 | if err != nil { |
| 293 | return nil, err |
| 294 | } |
| 295 | num := len(blocks) |
| 296 | var data []byte |
| 297 | for i, b := range blocks { |
| 298 | if i != b.block { |
| 299 | // We can't have missing blocks. |
| 300 | return nil, fmt.Errorf("gap in block list, found block %d at index %d", b.block, i) |
| 301 | } |
| 302 | bl := uint64(len(b.data)) |
| 303 | if bl == 0 { |
| 304 | return nil, fmt.Errorf("empty block found at %d (out of %d blocks)", i, num) |
| 305 | } |
| 306 | if i != (num-1) && bl != BlockSize { |
| 307 | return nil, fmt.Errorf("non-blocksize %d at %d (out of %d blocks)", bl, i, num) |
| 308 | } |
| 309 | data = append(data, b.data...) |
| 310 | } |
| 311 | return data, nil |
| 312 | } |
| 313 | |
| 314 | func TestBlockInfo(t *testing.T) { |
| 315 | testCases := []struct { |
no test coverage detected