mirror of
https://github.com/rqlite/rqlite.git
synced 2026-01-25 04:16:26 +00:00
More consistent use of uploader sums
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"expvar"
|
||||
@@ -186,11 +185,11 @@ func (u *Uploader) upload(ctx context.Context) error {
|
||||
if u.lastModified.IsZero() {
|
||||
// No "last modified" time, so this must be the first upload since this
|
||||
// uploader started. Double-check that we really need to upload.
|
||||
cloudSum, err := u.storageClient.CurrentSum(ctx)
|
||||
cloudSum, err := u.currentSum(ctx)
|
||||
if err != nil {
|
||||
stats.Add(numSumGetFail, 1)
|
||||
u.logger.Printf("failed to get current sum from %s: %v", u.storageClient, err)
|
||||
} else if err == nil && bytes.Equal(cloudSum, filesum) {
|
||||
} else if err == nil && filesum.Equals(cloudSum) {
|
||||
stats.Add(numUploadsSkippedSum, 1)
|
||||
return nil
|
||||
}
|
||||
@@ -214,6 +213,14 @@ func (u *Uploader) upload(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *Uploader) currentSum(ctx context.Context) (SHA256Sum, error) {
|
||||
s, err := u.storageClient.CurrentSum(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return SHA256Sum(s), nil
|
||||
}
|
||||
|
||||
func (u *Uploader) compressIfNeeded(path string) error {
|
||||
if !u.compress {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user