diff options
| author | 2026-03-31 02:09:47 +0000 | |
|---|---|---|
| committer | 2026-03-31 02:14:33 +0000 | |
| commit | 6634953afb1af520ed6e523d96e58031b55058ac (patch) | |
| tree | d670a2eb9af032ec8d33f933e48a78135bffceea /network/receivepack | |
| parent | *: Fix lints (diff) | |
| signature | No signature | |
ref/store: Shape Batch a bit more like Transaction and eagerly validate what we could.
Diffstat (limited to 'network/receivepack')
| -rw-r--r-- | network/receivepack/service/apply.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/network/receivepack/service/apply.go b/network/receivepack/service/apply.go index 8dcc004f..fdf3eef6 100644 --- a/network/receivepack/service/apply.go +++ b/network/receivepack/service/apply.go @@ -57,7 +57,15 @@ func (service *Service) applyBatch(result *Result, commands []Command) error { } for _, command := range commands { - queueWriteBatch(batch, command) + err = queueWriteBatch(batch, command) + if err != nil { + _ = batch.Abort() + + fillCommandErrors(result, commands, err.Error()) + utils.BestEffortFprintf(service.opts.Progress, "updating refs: failed while queueing batch.\n") + + return nil + } } batchResults, err := batch.Apply() @@ -107,20 +115,16 @@ func queueWriteTransaction(tx refstore.Transaction, command Command) error { return tx.Update(command.Name, command.NewID, command.OldID) } -func queueWriteBatch(batch refstore.Batch, command Command) { +func queueWriteBatch(batch refstore.Batch, command Command) error { if isDelete(command) { - batch.Delete(command.Name, command.OldID) - - return + return batch.Delete(command.Name, command.OldID) } if command.OldID == command.OldID.Algorithm().Zero() { - batch.Create(command.Name, command.NewID) - - return + return batch.Create(command.Name, command.NewID) } - batch.Update(command.Name, command.NewID, command.OldID) + return batch.Update(command.Name, command.NewID, command.OldID) } func successCommandResult(command Command) CommandResult { |
