forget - missing lock for 'failedSnIDs' (#22100)

This commit is contained in:
Winfried Plappert authored and GitHub committed 2026-10-11 22:15:25 +02:00
1 parent 519a979107
commit 9da3b87b07
1 file changed
+4
+4
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"strconv"
"sync"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
@@ -317,10 +318,13 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
if len(removeSnIDs) > 0 {
if !opts.DryRun {
bar := printer.NewCounter("files deleted")
var lock sync.Mutex
err := restic.ParallelRemove(ctx, repo, removeSnIDs, restic.WriteableSnapshotFile, func(id restic.ID, err error) error {
if err != nil {
printer.E("unable to remove %v/%v from the repository\n", restic.SnapshotFile, id)
lock.Lock()
failedSnIDs.Insert(id)
lock.Unlock()
} else {
printer.VV("removed %v/%v\n", restic.SnapshotFile, id)
}