aboutsummaryrefslogtreecommitdiff
path: root/network/receivepack/service/apply.go
diff options
context:
space:
mode:
Diffstat (limited to 'network/receivepack/service/apply.go')
-rw-r--r--network/receivepack/service/apply.go22
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 {