Verified Commit 0b3e5edd authored by boklm's avatar boklm
Browse files

Bug 41607: Fix regression from #41373 in count-mar-downloads

Before 610da963 the _ALL\.mar in the
regular expression used to parse full mar filenames was excluding the
incremental\.mar. When making the _ALL part optional the regular
expression incorrectly matches incremental mar filenames.

To fix that we now parse the path in two steps:
- we get the version number from the directory, and the mar filename
- we parse the mar filename using the version number we know from the
  directory
parent 109be58b
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -62,17 +62,20 @@ sub parse_log_file {

  my ($stdout, undef, $success) = capture_exec('xzcat', $File::Find::name);
  foreach my $line (split /\n/, $stdout) {
    my ($version, $os) =
      ($line =~ m|^[^\s]+ - - \[.+\] "GET /aus1/torbrowser/([^/]+)/tor-browser-(.*)-\d.*(_ALL)?\.mar HTTP/|);
    if ($version) {
    my ($version, $filename) =
      ($line =~ m|^[^\s]+ - - \[.+\] "GET /aus1/torbrowser/([^/]+)/(tor-browser-.*\.mar) HTTP/|);
    next unless $filename;
    my ($os) =
      ($filename =~ m|^tor-browser-(.*)-\Q$version\E(_ALL)?\.mar$|);
    if ($os) {
      $downloads{$version}{total} += 1;
      $downloads{$version}{full_update} += 1;
      $downloads{$version}{OS}{$os} += 1;
      next;
    }
    my $incremental_from;
    ($version, $os, $incremental_from) =
      ($line =~ m|^[^\s]+ - - \[.+\] "GET /aus1/torbrowser/([^/]+)/tor-browser-(.*)--(\d[^-]+)-.*(_ALL)?\.incremental\.mar HTTP/|);
    ($os, $incremental_from) =
      ($filename =~ m|^tor-browser-(.*)--(\d[^-]+)-\Q$version\E(_ALL)?\.incremental\.mar$|);
    if ($incremental_from) {
      $downloads{$version}{total} += 1;
      $downloads{$version}{OS}{$os} += 1;