Skip to content

Commit

Permalink
fix: missing one parameter of Set function for gopkg.in/cheggaaa/pb
Browse files Browse the repository at this point in the history
when updating the package gopkg.in/cheggaaa/pb.v2 to v2.0.7.

Signed-off-by: James Lu <james.lu@suse.com>
  • Loading branch information
mantissahz committed Feb 23, 2024
1 parent 8cbf9ba commit 6d59342
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/cmd/restore_to_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ 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
restoreError := restoreObj.Error
restoreObj.Unlock()

if restoreProgress == 100 {
bar.Set(restoreProgress)
bar.Set(progressKeyName, restoreProgress)
bar.Finish()
periodicChecker.Stop()
return nil
Expand All @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"syscall"
"time"

"github.com/google/uuid"
"github.com/gorilla/handlers"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
Expand All @@ -30,6 +31,8 @@ var (

const (
BlockSizeLinux = 512

RandomIDLenth = 8
)

func ParseAddresses(name string) (string, string, string, int, error) {
Expand Down Expand Up @@ -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]
}

0 comments on commit 6d59342

Please sign in to comment.