1
0
Fork 0

More comments

master
Philip O'Toole 8 months ago
parent 0d81e6f438
commit f3c1109325

@ -16,8 +16,13 @@ import (
// StorageClient is an interface for uploading data to a storage service.
type StorageClient interface {
// Upload uploads the data from the given reader to the storage service.
// sum is the SHA256 sum of the data being uploaded and will be stored with
// the data. If sum is nil, no sum will be stored.
Upload(ctx context.Context, reader io.Reader, sum []byte) error
// LastSum returns the SHA256 sum of the data in the Storage service.
// It is always read from the Storage service and never cached.
LastSum(ctx context.Context) ([]byte, error)
fmt.Stringer
@ -130,7 +135,7 @@ func (u *Uploader) Stats() (map[string]interface{}, error) {
"compress": u.compress,
"last_upload_time": u.lastUploadTime.Format(time.RFC3339),
"last_upload_duration": u.lastUploadDuration.String(),
"last_sum": fmt.Sprintf("%x", u.lastSum),
"last_sum_uploaded": fmt.Sprintf("%x", u.lastSum),
"last_modified": u.lastModified.String(),
}
return status, nil

@ -105,6 +105,8 @@ func (s *S3Client) Upload(ctx context.Context, reader io.Reader, sum []byte) err
return nil
}
// LastSum returns the last SHA256 sum uploaded to S3. It is always read from
// S3 and never cached.
func (s *S3Client) LastSum(ctx context.Context) ([]byte, error) {
sess, err := s.createSession()
if err != nil {

Loading…
Cancel
Save