From 6d5934297eca559b00a8baf54abc2cdf9c89b00a Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 23 Feb 2024 10:31:55 +0800 Subject: [PATCH] fix: missing one parameter of Set function for gopkg.in/cheggaaa/pb when updating the package gopkg.in/cheggaaa/pb.v2 to v2.0.7. Signed-off-by: James Lu --- app/cmd/restore_to_file.go | 5 +++-- pkg/util/util.go | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/cmd/restore_to_file.go b/app/cmd/restore_to_file.go index 68b142f65..0497c7095 100644 --- a/app/cmd/restore_to_file.go +++ b/app/cmd/restore_to_file.go @@ -94,6 +94,7 @@ func restore(url string, concurrentLimit int) error { bar := pb.StartNew(100) periodicChecker := time.NewTicker(PeriodicRefreshIntervalInSeconds * time.Second) + progressKeyName := requestedBackupName + util.RandomID() for range periodicChecker.C { restoreObj.Lock() restoreProgress := restoreObj.Progress @@ -101,7 +102,7 @@ func restore(url string, concurrentLimit int) error { restoreObj.Unlock() if restoreProgress == 100 { - bar.Set(restoreProgress) + bar.Set(progressKeyName, restoreProgress) bar.Finish() periodicChecker.Stop() return nil @@ -111,7 +112,7 @@ func restore(url string, concurrentLimit int) error { periodicChecker.Stop() return fmt.Errorf("%v", restoreError) } - bar.Set(restoreProgress) + bar.Set(progressKeyName, restoreProgress) } return nil } diff --git a/pkg/util/util.go b/pkg/util/util.go index d1e11204f..7d63fec8b 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -14,6 +14,7 @@ import ( "syscall" "time" + "github.com/google/uuid" "github.com/gorilla/handlers" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" @@ -30,6 +31,8 @@ var ( const ( BlockSizeLinux = 512 + + RandomIDLenth = 8 ) func ParseAddresses(name string) (string, string, string, int, error) { @@ -284,3 +287,7 @@ func GetAddresses(volumeName, address string, dataServerProtocol types.DataServe return "", "", "", -1, fmt.Errorf("unsupported protocol: %v", dataServerProtocol) } } + +func RandomID() string { + return uuid.New().String()[:RandomIDLenth] +}