fix: add update log queue rejection

This commit is contained in:
Stefan Martinov 2019-10-25 16:37:05 +02:00
parent 620291db4a
commit 934b1dc9c4
2 changed files with 7 additions and 5 deletions

View File

@ -223,7 +223,7 @@ func (repo *Repo) tryUpdate() (repoRuntime int64, err error) {
return ur.repoRuntime, ur.err
default:
Log.Info("update request accepted, will be processed after the previous update")
return 0, nil
return 0, errUpdateRejected
}
}

View File

@ -255,13 +255,15 @@ func (repo *Repo) Update() (updateResponse *responses.Update) {
updateResponse.Success = false
updateResponse.Stats.NumberOfNodes = -1
updateResponse.Stats.NumberOfURIs = -1
// let us try to restore the world from a file
Log.Error("could not update repository:", zap.Error(updateErr))
// Log.Info(ansi.Yellow + "BUFFER LENGTH AFTER ERROR: " + strconv.Itoa(len(repo.jsonBuf.Bytes())) + ansi.Reset)
updateResponse.ErrorMessage = updateErr.Error()
// let us try to restore the world from a file
// Log.Info(ansi.Yellow + "BUFFER LENGTH AFTER ERROR: " + strconv.Itoa(len(repo.jsonBuf.Bytes())) + ansi.Reset)
// only try to restore if the update failed during processing
if updateErr != errUpdateRejected {
updateResponse.ErrorMessage = updateErr.Error()
Log.Error("could not update repository:", zap.Error(updateErr))
restoreErr := repo.tryToRestoreCurrent()
if restoreErr != nil {
Log.Error("failed to restore preceding repo version", zap.Error(restoreErr))