diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 08d2aef3..01651c3d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -30,7 +30,11 @@ jobs: run: ./scripts/install-deps.sh - name: Build - run: ./scripts/build.sh + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: build --snapshot --clean - name: Test run: PATH=$(pwd):$PATH go test ./... diff --git a/internal/oplog/oplog.go b/internal/oplog/oplog.go index 8b59fcfa..f5d6db27 100644 --- a/internal/oplog/oplog.go +++ b/internal/oplog/oplog.go @@ -183,12 +183,12 @@ func (o *OpLog) Update(op *v1.Operation) error { func (o *OpLog) Delete(id int64) error { err := o.db.Update(func(tx *bolt.Tx) error { - val := tx.Bucket(OpLogBucket).Get(serializationutil.Itob(op.Id)) + val := tx.Bucket(OpLogBucket).Get(serializationutil.Itob(id)) if val == nil { return ErrNotExist } if err := o.deleteOperationHelper(tx, id); err != nil { - return fmt.Errorf("deleting operation %v: %w", op.Id, err) + return fmt.Errorf("deleting operation %v: %w", id, err) } b := tx.Bucket(OpLogSoftDeleteBucket) diff --git a/internal/orchestrator/forget.go b/internal/orchestrator/forget.go index 859be835..87682a45 100644 --- a/internal/orchestrator/forget.go +++ b/internal/orchestrator/forget.go @@ -8,6 +8,8 @@ import ( "time" v1 "github.com/garethgeorge/resticui/gen/go/v1" + "github.com/garethgeorge/resticui/internal/oplog/indexutil" + "github.com/hashicorp/go-multierror" "go.uber.org/zap" ) @@ -85,13 +87,14 @@ func (t *ForgetTask) Run(ctx context.Context) error { forgetOp.OperationForget.Forget = append(forgetOp.OperationForget.Forget, forgot...) for _, forgot := range forgot { - t.orchestrator.OpLog.ForEachBySnapshotId(forgot.Id, func(op *v1.Operation) error { + if e := t.orchestrator.OpLog.ForEachBySnapshotId(forgot.Id, indexutil.CollectAll(), func(op *v1.Operation) error { return t.orchestrator.OpLog.Delete(op.Id) - }) - + }); e != nil { + err = multierror.Append(err, fmt.Errorf("cleanup snapshot %v: %w", forgot.Id, e)) + } } - return nil + return err }); err != nil { return err }