Only set OldStatus once to avoid issues in case the status is changed multiple times before the job is saved.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/WineTestBot/Jobs.pm | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm index 3da6ae7b0..b54f864da 100644 --- a/testbot/lib/WineTestBot/Jobs.pm +++ b/testbot/lib/WineTestBot/Jobs.pm @@ -92,15 +92,6 @@ use WineTestBot::Engine::Notify; use WineTestBot::TaskFailures;
-sub _initialize($$) -{ - my ($self, $Collection) = @_; - - $self->SUPER::_initialize($Collection); - - $self->{OldStatus} = undef; -} - sub InitializeNew($$) { my ($self, $Collection) = @_; @@ -171,10 +162,10 @@ sub Status($;$) my $CurrentStatus = $self->SUPER::Status; return $CurrentStatus if (!defined $NewStatus);
- if (! defined($CurrentStatus) || $NewStatus ne $CurrentStatus) + if (!defined $CurrentStatus or $NewStatus ne $CurrentStatus) { + $self->{OldStatus} ||= $CurrentStatus; $self->SUPER::Status($NewStatus); - $self->{OldStatus} = $CurrentStatus; }
return $NewStatus; @@ -185,15 +176,11 @@ sub OnSaved($) my ($self) = @_;
$self->SUPER::OnSaved(); - - if (defined($self->{OldStatus})) + if (defined $self->{OldStatus} and $self->{OldStatus} ne $self->Status) { - my $NewStatus = $self->Status; - if ($NewStatus ne $self->{OldStatus}) - { - JobStatusChange($self->GetKey(), $self->{OldStatus}, $NewStatus); - } + JobStatusChange($self->GetKey(), $self->{OldStatus}, $self->Status); } + delete $self->{OldStatus}; }
=pod