mirror of
https://github.com/restic/restic.git
synced 2026-05-30 22:05:24 +00:00
parallelize more List usages
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -301,15 +302,15 @@ func RemoveStaleLocks(ctx context.Context, repo Repository) (uint, error) {
|
||||
|
||||
// RemoveAllLocks removes all locks forcefully.
|
||||
func RemoveAllLocks(ctx context.Context, repo Repository) (uint, error) {
|
||||
var processed uint
|
||||
err := repo.List(ctx, LockFile, func(id ID, size int64) error {
|
||||
var processed uint32
|
||||
err := ParallelList(ctx, repo.Backend(), LockFile, repo.Connections(), func(ctx context.Context, id ID, size int64) error {
|
||||
err := repo.Backend().Remove(ctx, Handle{Type: LockFile, Name: id.String()})
|
||||
if err == nil {
|
||||
processed++
|
||||
atomic.AddUint32(&processed, 1)
|
||||
}
|
||||
return err
|
||||
})
|
||||
return processed, err
|
||||
return uint(processed), err
|
||||
}
|
||||
|
||||
// ForAllLocks reads all locks in parallel and calls the given callback.
|
||||
|
||||
Reference in New Issue
Block a user