mtorluemke closed pull request #2095: ORT updates .cer files if generated file 
would be different, including order
URL: https://github.com/apache/incubator-trafficcontrol/pull/2095
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/bin/traffic_ops_ort.pl 
b/traffic_ops/bin/traffic_ops_ort.pl
index 32d25baa4..32a8e99cb 100755
--- a/traffic_ops/bin/traffic_ops_ort.pl
+++ b/traffic_ops/bin/traffic_ops_ort.pl
@@ -385,19 +385,29 @@ sub process_cfg_file {
                @disk_file_lines = @{ &open_file_get_contents($file) };
        }
 
-       my @return             = &diff_file_lines( $cfg_file, \@db_file_lines, 
\@disk_file_lines );
-       my @db_lines_missing   = @{ shift(@return) };
-       my @disk_lines_missing = @{ shift(@return) };
+       # First, check if the file to be generated would be identical including 
order
+       my $change_needed = ( join( '\0', @disk_file_lines ) ne join( '\0', 
@db_file_lines ) );
 
-       if ( ($cfg_file eq "logs_xml.config" && !(@disk_file_lines ~~ 
@db_file_lines))
-               || scalar(@disk_lines_missing) || scalar(@db_lines_missing) ) {
-               $cfg_file_tracker->{$cfg_file}->{'change_needed'}++;
+       # if different, look deeper to see if we care about the diffs (e.g. 
different order)
+       if ( $change_needed && !( $cfg_file eq 'logs_xml.config' || $cfg_file 
=~ /\.cer$/ ) ) {
+               my @return             = &diff_file_lines( $cfg_file, 
\@db_file_lines, \@disk_file_lines );
+               my @db_lines_missing   = @{ shift(@return) };
+               my @disk_lines_missing = @{ shift(@return) };
+
+               if ( scalar(@disk_lines_missing) == 0 && 
scalar(@db_lines_missing) == 0 ) {
+                       # all lines accounted for
+                       $change_needed = undef;
+               }
+       }
+
+       if ($change_needed) {
+               $cfg_file_tracker->{$cfg_file}{'change_needed'}++;
                ( $log_level >> $DEBUG ) && print "DEBUG $file needs 
updated.\n";
                &backup_file( $cfg_file, \$result );
        }
        else {
                ( $log_level >> $INFO ) && print "INFO: All lines match TrOps 
for config file: $cfg_file.\n";
-               $cfg_file_tracker->{$cfg_file}->{'change_needed'} = 0;
+               $cfg_file_tracker->{$cfg_file}{'change_needed'} = 0;
                ( $log_level >> $TRACE ) && print "TRACE Setting change not 
needed for $cfg_file.\n";
                $return_code = $CFG_FILE_UNCHANGED;
        }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to