Skip to content

Commit

Permalink
Add error handling for hash computaiton of delta snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Swapnil Mhamane <[email protected]>
  • Loading branch information
Swapnil Mhamane committed Dec 11, 2018
1 parent d960b82 commit 21aabc1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/snapshot/snapshotter/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"io"
"path"
"sync"
"time"
Expand Down Expand Up @@ -250,10 +251,12 @@ func (ssr *Snapshotter) takeDeltaSnapshot() error {
}
// compute hash
hash := sha256.New()
hash.Write(data)
if _, err := io.Copy(hash, bytes.NewReader(data)); err != nil {
return fmt.Errorf("failed to compute hash of events: %v", err)
}
data = hash.Sum(data)
dataReader := bytes.NewReader(data)

dataReader := bytes.NewReader(data)
if err := ssr.config.store.Save(*snap, dataReader); err != nil {
ssr.logger.Errorf("Error saving delta snapshots. %v", err)
return err
Expand Down

0 comments on commit 21aabc1

Please sign in to comment.