From 9816bb51480663c5b906fbc107542fbfaddc256c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 24 Feb 2021 10:46:34 +0000 Subject: [PATCH] #769 Numeric sort error for logfile rotation --- Changes | 6 ++++++ bin/netdisco-backend | 2 +- bin/netdisco-web | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 292fecaf..4c887436 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.047005 - 2021-02-24 + + [BUG FIXES] + + * #769 Numeric sort error for logfile rotation + 2.047004 - 2021-02-15 [BUG FIXES] diff --git a/bin/netdisco-backend b/bin/netdisco-backend index c9ceb78e..4fb057bf 100755 --- a/bin/netdisco-backend +++ b/bin/netdisco-backend @@ -168,7 +168,7 @@ sub rotate_logs { ((-s $log_file) > ($logsize * 1024768)); my @files = grep { /$log_file\.\d+/ } glob file($log_dir, '*'); - foreach my $f (sort { $b <=> $a } @files) { + foreach my $f (sort { $b cmp $a } @files) { next unless $f =~ m/$log_file\.(\d+)$/; my $pos = $1; unlink $f if $pos == ($logfiles - 1); diff --git a/bin/netdisco-web b/bin/netdisco-web index 25678d3c..7e54bb7a 100755 --- a/bin/netdisco-web +++ b/bin/netdisco-web @@ -183,7 +183,7 @@ sub rotate_logs { ((-s $log_file) > ($logsize * 1024768)); my @files = grep { /$log_file\.\d+/ } glob file($log_dir, '*'); - foreach my $f (sort { $b <=> $a } @files) { + foreach my $f (sort { $b cmp $a } @files) { next unless $f =~ m/$log_file\.(\d+)$/; my $pos = $1; unlink $f if $pos == ($logfiles - 1);