[pve-devel] [PATCH common] fix #1766: compare task starttime numerically

Wolfgang Bumiller w.bumiller at proxmox.com
Wed May 16 08:54:55 CEST 2018


Not only because <=> is correct, but using 'cmp' also has
the side effect that it adds a string version to the
variable and the API's json output turns into a string as
well, and this only happens once a task has completed
(while it's an integer while it's still running...)

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/PVE/RESTEnvironment.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index ebf8a2e..32ffdd1 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -270,7 +270,7 @@ sub active_workers  {
 	}
 
 
-	@ta = sort { $b->{starttime} cmp $a->{starttime} } @ta;
+	@ta = sort { $b->{starttime} <=> $a->{starttime} } @ta;
 
 	my $save = defined($new_upid);
 
-- 
2.11.0




More information about the pve-devel mailing list