diff options
| author | 2026-03-23 05:17:56 +0000 | |
|---|---|---|
| committer | 2026-03-23 05:17:56 +0000 | |
| commit | f6a087d759e7b5319432bc79cd3941d1bd3639c9 (patch) | |
| tree | cdcce86a3e4689930ef5a1346ab41cf942298057 /refstore/files/batch_apply.go | |
| parent | *: Lints (diff) | |
| signature | No signature | |
refstore/files: Pretty big logical restructure ish lint fix for batch Apply v0.1.94
Diffstat (limited to 'refstore/files/batch_apply.go')
| -rw-r--r-- | refstore/files/batch_apply.go | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/refstore/files/batch_apply.go b/refstore/files/batch_apply.go index b4ba16ad..5746aef5 100644 --- a/refstore/files/batch_apply.go +++ b/refstore/files/batch_apply.go @@ -57,34 +57,14 @@ func (batch *Batch) Apply() ([]refstore.BatchResult, error) { for len(remainingOps) > 0 { prepared, err := executor.prepareUpdates(remainingOps) - if err != nil { - if isBatchRejected(err) { - name := batchResultName(err) - rejectedAt := -1 - - for i, op := range remainingOps { - if op.name == name { - rejectedAt = i - - break - } - } - - if rejectedAt < 0 { - for _, idx := range remainingIdx { - results[idx].Status = refstore.BatchStatusNotAttempted - results[idx].Error = batchResultError(err) - } - - return results, err + if err == nil { + err = executor.commitPreparedUpdates(prepared) + if err == nil { + for _, idx := range remainingIdx { + results[idx].Status = refstore.BatchStatusApplied } - results[remainingIdx[rejectedAt]].Status = refstore.BatchStatusRejected - results[remainingIdx[rejectedAt]].Error = batchResultError(err) - remainingIdx = append(remainingIdx[:rejectedAt], remainingIdx[rejectedAt+1:]...) - remainingOps = append(remainingOps[:rejectedAt], remainingOps[rejectedAt+1:]...) - - continue + return results, nil } fatalName := batchResultName(err) @@ -106,8 +86,7 @@ func (batch *Batch) Apply() ([]refstore.BatchResult, error) { return results, err } - err = executor.commitPreparedUpdates(prepared) - if err != nil { + if !isBatchRejected(err) { fatalName := batchResultName(err) fatalMarked := false @@ -127,11 +106,30 @@ func (batch *Batch) Apply() ([]refstore.BatchResult, error) { return results, err } - for _, idx := range remainingIdx { - results[idx].Status = refstore.BatchStatusApplied + name := batchResultName(err) + rejectedAt := -1 + + for i, op := range remainingOps { + if op.name == name { + rejectedAt = i + + break + } + } + + if rejectedAt < 0 { + for _, idx := range remainingIdx { + results[idx].Status = refstore.BatchStatusNotAttempted + results[idx].Error = batchResultError(err) + } + + return results, err } - return results, nil + results[remainingIdx[rejectedAt]].Status = refstore.BatchStatusRejected + results[remainingIdx[rejectedAt]].Error = batchResultError(err) + remainingIdx = append(remainingIdx[:rejectedAt], remainingIdx[rejectedAt+1:]...) + remainingOps = append(remainingOps[:rejectedAt], remainingOps[rejectedAt+1:]...) } return results, nil |
