Implement continuity handoffs and pickup validation
This commit is contained in:
@@ -209,6 +209,21 @@ func (s *Store) PutArtifact(b []byte) (string, error) {
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// Artifact returns a CAS artifact after verifying its content address.
|
||||
func (s *Store) Artifact(ref string) ([]byte, error) {
|
||||
if len(ref) != 64 {
|
||||
return nil, fmt.Errorf("%w: invalid artifact reference", domain.ErrInvalid)
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join(s.cas, ref))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if domain.Hash(b) != ref {
|
||||
return nil, fmt.Errorf("%w: corrupt artifact", domain.ErrInvalid)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (s *Store) Task(id string) (domain.Task, bool) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user