updateCachedShippedBlocks reads the shipper meta file and updates the cached shipped blocks.
()
| 606 | |
| 607 | // updateCachedShippedBlocks reads the shipper meta file and updates the cached shipped blocks. |
| 608 | func (u *userTSDB) updateCachedShippedBlocks() error { |
| 609 | shipperMeta, err := shipper.ReadMetaFile(u.shipperMetadataFilePath) |
| 610 | if os.IsNotExist(err) || os.IsNotExist(errors.Cause(err)) { |
| 611 | // If the meta file doesn't exist it means the shipper hasn't run yet. |
| 612 | shipperMeta = &shipper.Meta{} |
| 613 | } else if err != nil { |
| 614 | return err |
| 615 | } |
| 616 | |
| 617 | // Build a map. |
| 618 | shippedBlocks := make(map[ulid.ULID]struct{}, len(shipperMeta.Uploaded)) |
| 619 | for _, blockID := range shipperMeta.Uploaded { |
| 620 | shippedBlocks[blockID] = struct{}{} |
| 621 | } |
| 622 | |
| 623 | // Cache it. |
| 624 | u.shippedBlocksMtx.Lock() |
| 625 | u.shippedBlocks = shippedBlocks |
| 626 | u.shippedBlocksMtx.Unlock() |
| 627 | |
| 628 | return nil |
| 629 | } |
| 630 | |
| 631 | // getCachedShippedBlocks returns the cached shipped blocks. |
| 632 | func (u *userTSDB) getCachedShippedBlocks() map[ulid.ULID]struct{} { |