mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-09-24 00:45:36 +00:00
fix: correctly mark tasks as inprogress before execution
This commit is contained in:
@@ -84,6 +84,9 @@ func (t *TaskWithOperation) Cancel(withStatus v1.OperationStatus) error {
|
||||
// timestamps are automatically added and the status is automatically updated if an error occurs.
|
||||
func WithOperation(oplog *oplog.OpLog, op *v1.Operation, do func() error) error {
|
||||
op.UnixTimeStartMs = curTimeMillis() // update the start time from the planned time to the actual time.
|
||||
if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN {
|
||||
op.Status = v1.OperationStatus_STATUS_INPROGRESS
|
||||
}
|
||||
if op.Id != 0 {
|
||||
if err := oplog.Update(op); err != nil {
|
||||
return fmt.Errorf("failed to add operation to oplog: %w", err)
|
||||
@@ -93,10 +96,6 @@ func WithOperation(oplog *oplog.OpLog, op *v1.Operation, do func() error) error
|
||||
return fmt.Errorf("failed to add operation to oplog: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN {
|
||||
op.Status = v1.OperationStatus_STATUS_INPROGRESS
|
||||
}
|
||||
err := do()
|
||||
if err != nil {
|
||||
op.Status = v1.OperationStatus_STATUS_ERROR
|
||||
|
||||
Reference in New Issue
Block a user