mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-09-21 23:45:36 +00:00
feat: forget soft-deletes operations associated with removed snapshots
This commit is contained in:
@@ -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 ./...
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user