Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package MirrorCache for openSUSE:Factory 
checked in at 2023-07-27 16:53:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/MirrorCache (Old)
 and      /work/SRC/openSUSE:Factory/.MirrorCache.new.32662 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "MirrorCache"

Thu Jul 27 16:53:05 2023 rev:29 rq:1101013 version:1.061

Changes:
--------
--- /work/SRC/openSUSE:Factory/MirrorCache/MirrorCache.changes  2023-06-22 
23:26:39.798025854 +0200
+++ /work/SRC/openSUSE:Factory/.MirrorCache.new.32662/MirrorCache.changes       
2023-07-27 16:53:19.942669868 +0200
@@ -1,0 +2,7 @@
+Thu Jul 20 07:08:51 UTC 2023 - Andrii Nikitin <andrii.niki...@suse.com>
+
+- Update to version 1.061:
+  * Add support of some parameters in ini file (#397)
+  * Fix html mirror report (#394)
+
+-------------------------------------------------------------------

Old:
----
  MirrorCache-1.060.obscpio

New:
----
  MirrorCache-1.061.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ MirrorCache.spec ++++++
--- /var/tmp/diff_new_pack.LiksZD/_old  2023-07-27 16:53:20.786674637 +0200
+++ /var/tmp/diff_new_pack.LiksZD/_new  2023-07-27 16:53:20.794674682 +0200
@@ -22,7 +22,7 @@
 %define main_requires %{assetpack_requires} perl(Carp) perl(DBD::Pg) >= 3.7.4 
perl(DBI) >= 1.632 perl(DBIx::Class) >= 0.082801 
perl(DBIx::Class::DynamicDefault) perl(DateTime) perl(Encode) perl(Time::Piece) 
perl(Time::Seconds) perl(Time::ParseDate) perl(DateTime::Format::Pg) 
perl(Exporter) perl(File::Basename) perl(LWP::UserAgent) perl(Mojo::Base) 
perl(Mojo::ByteStream) perl(Mojo::IOLoop) perl(Mojo::JSON) perl(Mojo::Pg) 
perl(Mojo::URL) perl(Mojo::Util) perl(Mojolicious::Commands) 
perl(Mojolicious::Plugin) perl(Mojolicious::Plugin::RenderFile) 
perl(Mojolicious::Static) perl(Net::OpenID::Consumer) perl(POSIX) 
perl(Sort::Versions) perl(URI::Escape) perl(XML::Writer) perl(base) 
perl(constant) perl(diagnostics) perl(strict) perl(warnings) shadow 
rubygem(sass) perl(Net::DNS) perl(LWP::Protocol::https) perl(Digest::SHA) 
perl(Config::IniFiles)
 %define build_requires %{assetpack_requires} rubygem(sass) tidy sysuser-shadow 
sysuser-tools
 Name:           MirrorCache
-Version:        1.060
+Version:        1.061
 Release:        0
 Summary:        WebApp to redirect and manage mirrors
 License:        GPL-2.0-or-later

++++++ MirrorCache-1.060.obscpio -> MirrorCache-1.061.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.060/lib/MirrorCache/Config.pm 
new/MirrorCache-1.061/lib/MirrorCache/Config.pm
--- old/MirrorCache-1.060/lib/MirrorCache/Config.pm     2023-06-15 
07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/Config.pm     2023-07-20 
08:47:03.000000000 +0200
@@ -24,6 +24,7 @@
 # For those values which may change it is better to use config file (the rest 
may be moved here as well)
 
 has root         => $ENV{MIRRORCACHE_ROOT};
+has root_nfs     => $ENV{MIRRORCACHE_ROOT_NFS};
 has dbuser       => $ENV{MIRRORCACHE_DBUSER};
 has dbpass       => $ENV{MIRRORCACHE_DBPASS};
 has dbhost       => $ENV{MIRRORCACHE_DBHOST};
@@ -39,6 +40,11 @@
 
 has redirect_huge  => $ENV{MIRRORCACHE_REDIRECT_HUGE};
 has huge_file_size => int($ENV{MIRRORCACHE_HUGE_FILE_SIZE} // 0) || 
40*1024*1024;
+has small_file_size => int($ENV{MIRRORCACHE_SMALL_FILE_SIZE} // 0);
+
+has city_mmdb     => $ENV{MIRRORCACHE_CITY_MMDB};
+has ip2location   => $ENV{MIRRORCACHE_IP2LOCATION};
+has top_folders   => $ENV{MIRRORCACHE_TOP_FOLDERS};
 
 has plugin_status => $ENV{MIRRORCACHE_PLUGIN_STATUS};
 
@@ -55,7 +61,7 @@
     my $cfg;
     $cfg = Config::IniFiles->new(-file => $cfgfile, -fallback => 'default') if 
$cfgfile;
     if ($cfg) {
-        for my $k (qw/root redirect mirror_provider browser_agent_mask/) {
+        for my $k (qw/root root_nfs redirect redirect_huge huge_file_size 
small_file_size city_mmdb ip2location top_folders mirror_provider 
browser_agent_mask custom_footer_message/) {
             if (my $v = $cfg->val('default', $k)) {
                 $self->$k($v);
             }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.060/lib/MirrorCache/Task/MirrorScan.pm 
new/MirrorCache-1.061/lib/MirrorCache/Task/MirrorScan.pm
--- old/MirrorCache-1.060/lib/MirrorCache/Task/MirrorScan.pm    2023-06-15 
07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/Task/MirrorScan.pm    2023-07-20 
08:47:03.000000000 +0200
@@ -69,7 +69,7 @@
     my $folder = $schema->resultset('Folder')->find({path => $path});
     return undef unless $folder && $folder->id; # folder is not added to db yet
     my $realpath;
-    if ($app->mc->root->is_remote && !$ENV{MIRRORCACHE_ROOT_NFS}) {
+    if ($app->mc->root->is_remote && !$app->mcconfig->root_nfs) {
         my $redirect = $schema->resultset('Redirect')->find({pathfrom => 
$path});
         $realpath = $redirect->pathto if $redirect;
     } else {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Controller/Report/Mirrors.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Report/Mirrors.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Controller/Report/Mirrors.pm   
2023-06-15 07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Report/Mirrors.pm   
2023-07-20 08:47:03.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 SUSE LLC
+# Copyright (C) 2022,2023 SUSE LLC
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,26 +34,16 @@
         $projects = \@projects_new if scalar(@projects_new);
     }
 
-    my $sql = 'select dt, body from report_body where report_id = 1 order by 
dt desc limit 1';
+    my ($report, $dt) = $self->mc->reportmirror->list;
+    return $self->render(text => 'Report unavailable', status => 500) unless 
$report;
 
-    eval {
-        my @res = $self->schema->storage->dbh->selectrow_array($sql);
-        my $body = $res[1];
-        my $hash = decode_json($body);
-
-        $self->stash;
-        $self->render(
-            "report/mirrors/index",
-            mirrors     => $hash,
-            projects    => $projects,
-            allprojects => $allprojects
-        );
-    };
-    my $error = $@;
-    if ($error) {
-         print STDERR "RESPMIRRORSREPORT : " . $error . "\n";
-         return $self->render(json => {error => $error}, status => 404);
-    }
+    $self->stash;
+    return $self->render(
+        "report/mirrors/index",
+        mirrors     => $report,
+        projects    => $projects,
+        allprojects => $allprojects
+    );
 }
 
 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Controller/Rest/ReportMirror.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Rest/ReportMirror.pm
--- 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Controller/Rest/ReportMirror.pm    
    2023-06-15 07:52:04.000000000 +0200
+++ 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Rest/ReportMirror.pm    
    2023-07-20 08:47:03.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 SUSE LLC
+# Copyright (C) 2022,2023 SUSE LLC
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,120 +22,15 @@
 my $last_cache_run;
 my $cache_filename = 'reportmirror';
 
-# Prototype below is a hack trying to achive:
-# - If there are subsidiaries (i.e. tag is not empty) - merge reports from DB 
for each subsidiary.
-# - If successfully read report from DB - save the structures into cache 
folder (eventually for each subsidiary as well); max - once per minute
-# - If there was an error reading from DB - show the structures from the cache
 sub list {
-    my ($self)  = @_;
+    my ($c)  = @_;
 
-    my $sql = 'select dt, body, tag from report_body where report_id = 1 order 
by dt desc limit 1';
+    my ($report, $dt) = $c->mc->reportmirror->list;
+    return $c->render(text => 'Report unavailable', status => 500) unless 
$report;
 
-    my $body;
-    my %body_reg;
-    my $dt;
-    my %dt_reg;
-    my $waserror = 1;
-    eval {
-        my @res = $self->schema->storage->dbh->selectrow_array($sql);
-        my $tag = $res[2];
-        if ($tag) {
-            $body = $self->_render_geo_from_db(\%body_reg, \%dt_reg);
-        } else {
-            $dt   = $res[0];
-            $body = $res[1];
-            my $report = decode_json($body);
-
-            $self->render(
-                json => { report => $report, dt => $res[0] }
-            );
-        }
-        $waserror = 0;
-    };
-    my $error = $@;
-    if ($waserror) {
-        my $report;
-        eval {
-            my $f = Mojo::File->new( $self->mcproject->cache_dir . 
"/$cache_filename.json" );
-            $body = $f->slurp;
-            return unless $body;
-            $report = decode_json($body);
-            my @report = @{ $report };
-            my @regions = $self->subsidiary->regions;
-            for my $region (@regions) {
-                next unless $region;
-                next if $self->subsidiary->is_local($region);
-                eval {
-                    my $f_reg = Mojo::File->new( $self->mcproject->cache_dir . 
"/$cache_filename$region.json" );
-                    my $bodyreg = $f_reg->slurp;
-                    my $json = decode_json($bodyreg) if $bodyreg;
-                    next unless $json;
-                    my @items = @{ $json };
-                    if (my $url = $self->subsidiary->url($region)) {
-                        for my $item (@items) {
-                            $item->{region} = ($item->{region} // '') . " 
($url)";
-                        }
-                    }
-                    push @report, @items;
-                };
-            }
-            $report = \@report;
-        };
-        return $self->render(
-            json => { report => $report }
-        ) if $report;
-
-        return $self->render(json => {error => $error}, status => 404);
-    }
-
-    return unless $self->mcproject->caching;
-
-    if (!$last_cache_run || 60 < time() - $last_cache_run) {
-        $last_cache_run = time();
-        eval {
-            my $f = Mojo::File->new( $self->mcproject->cache_dir . 
"/$cache_filename.json" );
-            $f->spurt($body) if $body;
-            my @regions = $self->subsidiary->regions;
-            for my $region (@regions) {
-                my $x = $body_reg{$region};
-                next unless $x;
-                $f = Mojo::File->new( $self->mcproject->cache_dir . 
"/$cache_filename$region.json" );
-                $f->spurt($x);
-            }
-            1;
-        }
-    }
-}
-
-sub _render_geo_from_db {
-    my ($self, $body_reg, $dt_reg) = @_;
-    my $sql = 'select dt, body, tag from report_body where report_id = 1 and 
tag = ? order by dt desc limit 1';
-    my @res = $self->schema->storage->dbh->selectrow_array($sql, {}, 'local');
-    my $body = $res[1];
-    my $report = decode_json($body);
-    my @report = @$report;
-    my %regions_res;
-    my @regions = $self->subsidiary->regions;
-    for my $region (@regions) {
-        next if $self->subsidiary->is_local($region);
-        my @res_reg = $self->schema->storage->dbh->selectrow_array($sql, {}, 
$region);
-        next unless @res_reg;
-        my $dtreg   = $res_reg[0];
-        my $bodyreg = $res_reg[1];
-        my $json = decode_json($bodyreg);
-        my @items = @{ $json->{report} };
-        $body_reg->{$region} = encode_json(\@items);
-        $dt_reg->{$region}   = $dtreg;
-        my $url = $self->subsidiary->url($region);
-        for my $item (@items) {
-            $item->{region} = $item->{region} . " ($url)";
-        }
-        push @report, @items if @items;
-    }
-    $self->render(
-        json => { report => \@report, dt => $res[0] }
+    $c->render(
+        json => { report => $report, dt => $dt }
     );
-    return $body;
 }
 
 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/Dir.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/Dir.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/Dir.pm  2023-06-15 
07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/Dir.pm  2023-07-20 
08:47:03.000000000 +0200
@@ -40,9 +40,10 @@
 
     $root = $app->mc->root;
     $mc_config = $app->mc->config;
+    my $top_folders = $mc_config->top_folders;
 
-    if ($ENV{MIRRORCACHE_TOP_FOLDERS}) {
-        @top_folders = split /[:,\s]+/, $ENV{MIRRORCACHE_TOP_FOLDERS};
+    if ($top_folders) {
+        @top_folders = split /[:,\s]+/, $top_folders;
     }
 
     $app->hook(
@@ -61,7 +62,7 @@
     my $reqpath = $c->req->url->path;
 
     my $top_folder;
-    if ($ENV{MIRRORCACHE_TOP_FOLDERS}) {
+    if (@top_folders) {
         if ($reqpath =~ /^\/+$/) {
             $top_folder = '/';
         } else {
@@ -322,7 +323,7 @@
     return undef if $dm->extra && (!$accept || !$dm->accept_all);
     my ($path, $trailing_slash) = $dm->path;
     # we can just render top folders
-    return _render_top_folders($dm) if $ENV{MIRRORCACHE_TOP_FOLDERS} && $path 
eq '/';
+    return _render_top_folders($dm) if @top_folders && $path eq '/';
     return $root->render_file_if_nfs($dm, $path) if $root->is_remote;
 
     # root is only local now
@@ -650,21 +651,20 @@
     return $c->render( 'dir', files => \@items, route => $dm->route, cur_path 
=> $dir, folder_id => $id );
 }
 
-my $SMALL_FILE_SIZE = int($ENV{MIRRORCACHE_SMALL_FILE_SIZE} // 0);
-my $ROOT_NFS = $ENV{MIRRORCACHE_ROOT_NFS};
-
 sub _render_small {
-    return undef unless $SMALL_FILE_SIZE && ($ROOT_NFS || !$root->is_remote );
     my $dm = shift;
+    my $root_nfs = $mc_config->root_nfs;
+    my $small_file_size = $mc_config->small_file_size;
+    return undef unless $small_file_size && ($root_nfs || !$root->is_remote );
     $dm->_init_path;
     return undef if ($dm->metalink && !$dm->accept_all) || ($dm->meta4 && 
!$dm->accept_all) || $dm->mirrorlist || $dm->zsync;
     my ($path, undef) = $dm->path;
     my $full;
-    return $root->render_file_if_small($dm, $path, $SMALL_FILE_SIZE) unless 
$ROOT_NFS;
-    $full = $ROOT_NFS . $path;
+    return $root->render_file_if_small($dm, $path, $small_file_size) unless 
$root_nfs;
+    $full = $root_nfs . $path;
     my $size;
     eval { $size = -s $full if -f $full; };
-    return undef unless (defined $size) && $size <= $SMALL_FILE_SIZE;
+    return undef unless (defined $size) && $size <= $small_file_size;
     my $c = $dm->c;
     $c->render_file(filepath => $full, content_type => $dm->mime);
     return 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/ReportMirror.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/ReportMirror.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/ReportMirror.pm 
1970-01-01 01:00:00.000000000 +0100
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/ReportMirror.pm 
2023-07-20 08:47:03.000000000 +0200
@@ -0,0 +1,140 @@
+# Copyright (C) 2023 SUSE LLC
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, see <http://www.gnu.org/licenses/>.
+
+package MirrorCache::WebAPI::Plugin::ReportMirror;
+use Mojo::Base 'Mojolicious::Plugin';
+
+use Mojo::JSON qw(decode_json encode_json);
+use Mojo::File;
+
+my $last_cache_run; # last time when we saved reports into cache
+my $last_error; # used to not spam log with errors
+
+my $cache_filename = 'reportmirror';
+
+sub register {
+    my ($c, $app) = @_;
+
+    $app->helper('mc.reportmirror.list' => \&_list);
+    return $c;
+}
+
+# Prototype below is a hack trying to achive:
+# - If there are subsidiaries (i.e. tag is not empty) - merge reports from DB 
for each subsidiary.
+# - If successfully read report from DB - save the structures into cache 
folder (eventually for each subsidiary as well); max - once per minute
+# - If there was an error reading from DB - show the structures from the cache
+sub _list {
+    my ($c)  = @_;
+
+    my $sql = 'select dt, body, tag from report_body where report_id = 1 order 
by dt desc limit 1';
+
+    my $body;
+    my %body_reg;
+    my %dt_reg;
+    my $waserror = 1;
+    my ($report, $dt);
+    eval {
+        my @res = $c->schema->storage->dbh->selectrow_array($sql);
+        my $tag = $res[2];
+        if ($tag) {
+            ($report, $dt, $body) = _list_geo_from_db($c, \%body_reg, 
\%dt_reg);
+        } else {
+            $dt   = $res[0];
+            $body = $res[1];
+            $report = decode_json($body);
+        }
+        $waserror = 0;
+    };
+    my $error = $@;
+    if ($waserror) {
+        eval {
+            my $f = Mojo::File->new( $c->mcproject->cache_dir . 
"/$cache_filename.json" );
+            $body = $f->slurp;
+            return unless $body;
+            $report = decode_json($body);
+            my @report = @{ $report };
+            my @regions = $c->subsidiary->regions;
+            for my $region (@regions) {
+                next unless $region;
+                next if $c->subsidiary->is_local($region);
+                eval {
+                    my $f_reg = Mojo::File->new( $c->mcproject->cache_dir . 
"/$cache_filename$region.json" );
+                    my $bodyreg = $f_reg->slurp;
+                    my $json = decode_json($bodyreg) if $bodyreg;
+                    next unless $json;
+                    my @items = @{ $json };
+                    if (my $url = $c->subsidiary->url($region)) {
+                        for my $item (@items) {
+                            $item->{region} = ($item->{region} // '') . " 
($url)";
+                        }
+                    }
+                    push @report, @items;
+                };
+            }
+            $report = \@report;
+        };
+
+        if (!$last_error || 300 < time() - $last_error ) {
+            $c->log->error("Error while loading report: " . ($error // 
'Unknown'));
+        }
+    } elsif ($c->mcproject->caching && (!$last_cache_run || 60 < time() - 
$last_cache_run)) {
+        $last_cache_run = time();
+        eval {
+            my $f = Mojo::File->new( $c->mcproject->cache_dir . 
"/$cache_filename.json" );
+            $f->spurt($body) if $body;
+            my @regions = $c->subsidiary->regions;
+            for my $region (@regions) {
+                my $x = $body_reg{$region};
+                next unless $x;
+                $f = Mojo::File->new( $c->mcproject->cache_dir . 
"/$cache_filename$region.json" );
+                $f->spurt($x);
+            }
+            1;
+        }
+    }
+    return ($report, $dt);
+}
+
+# $body_reg will contain report for each subsidiary, so we can cache them later
+# $dt_reg contains time of report for each region
+sub _list_geo_from_db {
+    my ($c, $body_reg, $dt_reg) = @_;
+    my $sql = 'select dt, body, tag from report_body where report_id = 1 and 
tag = ? order by dt desc limit 1';
+    my @res = $c->schema->storage->dbh->selectrow_array($sql, {}, 'local');
+    my $body = $res[1];
+    my $report = decode_json($body);
+    my @report = @$report;
+    my %regions_res;
+    my @regions = $c->subsidiary->regions;
+    for my $region (@regions) {
+        next if $c->subsidiary->is_local($region);
+        my @res_reg = $c->schema->storage->dbh->selectrow_array($sql, {}, 
$region);
+        next unless @res_reg;
+        my $dtreg   = $res_reg[0];
+        my $bodyreg = $res_reg[1];
+        my $json = decode_json($bodyreg);
+        my @items = @{ $json->{report} };
+        $body_reg->{$region} = encode_json(\@items);
+        $dt_reg->{$region}   = $dtreg;
+        my $url = $c->subsidiary->url($region);
+        for my $item (@items) {
+            $item->{region} = $item->{region} . " ($url)";
+        }
+        push @report, @items if @items;
+    }
+    return (\@report, $res[0], $body);
+}
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm    
2023-06-15 07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm    
2023-07-20 08:47:03.000000000 +0200
@@ -33,6 +33,9 @@
 has 'urlredirect';
 has 'urlredirect_huge';
 has 'huge_file_size';
+has 'top_folders';
+
+my %TOP_FOLDERS;
 
 sub register {
     (my $self, $app) = @_;
@@ -46,6 +49,13 @@
     $self->urlredirect($app->mcconfig->redirect);
     $self->urlredirect_huge($app->mcconfig->redirect_huge);
     $self->huge_file_size($app->mcconfig->huge_file_size);
+    $self->top_folders($app->mcconfig->top_folders);
+    my $top_folders=$app->mcconfig->top_folders;
+    if ($top_folders) {
+        for my $folder (split(' ', $top_folders)) {
+            $TOP_FOLDERS{$folder} = 1;
+        }
+    }
 
     $app->helper( 'mc.root' => sub { $self; });
 }
@@ -153,13 +163,6 @@
 }
 
 
-my $TOP_FOLDERS=$ENV{MIRRORCACHE_TOP_FOLDERS};
-my %TOP_FOLDERS;
-if ($TOP_FOLDERS) {
-    for my $folder (split(' ', $TOP_FOLDERS)) {
-        $TOP_FOLDERS{$folder} = 1;
-    }
-}
 
 sub _detect_ln_in_the_same_folder {
     my ($dir, $file) = @_;
@@ -200,7 +203,7 @@
             next if $P && $f->basename !~ $P;
             my $stat = $f->stat;
             if ($stat) {
-                if (($dir eq '/' || $dir eq $root_subtree) && $TOP_FOLDERS) {
+                if (($dir eq '/' || $dir eq $root_subtree) && %TOP_FOLDERS) {
                     if (-d $f) {
                         return undef unless $TOP_FOLDERS{$f->basename};
                     }
@@ -228,7 +231,7 @@
             my $f = shift;
             return undef if $re1 && $f->basename !~ /$re1/;
             return undef if $re2 && $f->basename !~ /$re2/;
-            if (($dir eq '/' || $dir eq $root_subtree) && $TOP_FOLDERS) {
+            if (($dir eq '/' || $dir eq $root_subtree) && %TOP_FOLDERS) {
                 if (-d $f) {
                     return undef unless $TOP_FOLDERS{$f->basename};
                 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm   
2023-06-15 07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm   
2023-07-20 08:47:03.000000000 +0200
@@ -26,15 +26,13 @@
 
 # rooturlredirect as defined in mcconfig->redirect
 # rooturlsredirect same as above just https
-has [ 'rooturl', 'rooturlredirect', 'rooturlredirects', 'rooturlredirectvpn', 
'rooturlredirectvpns' ];
+has [ 'rooturl', 'rooturlredirect', 'rooturlredirects', 'rooturlredirectvpn', 
'rooturlredirectvpns', 'rootnfs', 'top_folders' ];
 
 # length of eventual path in rooturl after hostname
 has rooturidirlenght => 0;
 
 my $uaroot = Mojo::UserAgent->new->max_redirects(10)->request_timeout(1);
 
-my $nfs = $ENV{MIRRORCACHE_ROOT_NFS};
-
 sub register {
     my ($self, $app) = @_;
     my $rooturl = $app->mc->rootlocation;
@@ -47,8 +45,13 @@
         }
     }
 
+    my $mcconfig = $app->mcconfig;
+
+    $self->rootnfs($mcconfig->root_nfs);
+    $self->top_folders($mcconfig->top_folders);
+
     my $redirect = $rooturl;
-    if ($redirect = $app->mcconfig->redirect) {
+    if ($redirect = $mcconfig->redirect) {
         $redirect  = "http://$redirect"; unless 'http://' eq substr($redirect, 
0, length('http://'));
     } else {
         $redirect = $rooturl;
@@ -57,7 +60,7 @@
     my $redirects = $redirect =~ s/http:/https:/r;
     $self->rooturlredirects($redirects);
 
-    if (my $redirectvpn = $app->mcconfig->redirect_vpn) {
+    if (my $redirectvpn = $mcconfig->redirect_vpn) {
         $redirectvpn = "http://$redirectvpn"; unless 'http://' eq 
substr($redirectvpn, 0, length('http://'));
         $self->rooturlredirectvpn($redirectvpn);
         my $redirectvpns = $redirectvpn =~ s/http:/https:/r;
@@ -73,6 +76,7 @@
 sub realpath {
     my ($self, $path, $deep) = @_;
     return undef unless $path;
+    my $nfs = $self->rootnfs;
 
     if ($nfs) {
         my $localpath = $nfs . $path;
@@ -139,7 +143,7 @@
 sub render_file {
     my ($self, $dm, $filepath, $not_miss) = @_;
     my $c = $dm->c;
-
+    my $nfs = $self->rootnfs;
     if ($nfs && $dm->must_render_from_root && -f $nfs . $filepath) {
         $c->render_file(filepath => $nfs . $filepath, content_type => 
$dm->mime, content_disposition => 'inline');
         $c->stat->redirect_to_root($dm, $not_miss);
@@ -152,8 +156,9 @@
 }
 
 sub render_file_if_nfs {
-    return undef unless $nfs;
     my ($self, $dm, $filepath) = @_;
+    my $nfs = $self->rootnfs;
+    return undef unless $nfs;
 
     my $c = $dm->c;
 
@@ -185,7 +190,7 @@
 
 sub _detect_ln_in_the_same_folder {
     my ($self, $dir, $file) = @_;
-
+    my $nfs = $self->rootnfs;
     unless ($nfs) {
         my $dir1 = $dir . '/';
         my $rootlocation = $self->rooturl;
@@ -237,8 +242,8 @@
     my $dir  = shift;
     my $sub  = shift;
     my $P    = shift;
-    if ($dir eq '/' && $ENV{MIRRORCACHE_TOP_FOLDERS}) {
-        for (split ' ', $ENV{MIRRORCACHE_TOP_FOLDERS}) {
+    if ($dir eq '/' && $self->top_folders) {
+        for (split ' ', $self->top_folders) {
             $sub->($_ . '/');
         }
         return 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.060/lib/MirrorCache/WebAPI.pm 
new/MirrorCache-1.061/lib/MirrorCache/WebAPI.pm
--- old/MirrorCache-1.060/lib/MirrorCache/WebAPI.pm     2023-06-15 
07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/WebAPI.pm     2023-07-20 
08:47:03.000000000 +0200
@@ -67,7 +67,8 @@
     my $mcconfig = $self->mcconfig;
     my $root     = $mcconfig->root;
 
-    my $geodb_file = $ENV{MIRRORCACHE_CITY_MMDB} || 
$ENV{MIRRORCACHE_IP2LOCATION};
+    my $geodb_file = $mcconfig->city_mmdb;
+    $geodb_file = $mcconfig->ip2location unless $geodb_file;
 
     die("Geo IP location database is not a file ($geodb_file)\nPlease check 
MIRRORCACHE_CITY_MMDB or MIRRORCACHE_IP2LOCATION") if $geodb_file && ! -f 
$geodb_file;
     my $geodb;
@@ -111,6 +112,7 @@
     $self->plugin('Backstage');
     $self->plugin('AuditLog');
     $self->plugin('RenderFileFromMirror');
+    $self->plugin('ReportMirror');
     $self->plugin('HashedParams');
 
     if ($geodb_file && $geodb_file =~ /\.mmdb$/i) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/resources/migrations/Pg.sql 
new/MirrorCache-1.061/lib/MirrorCache/resources/migrations/Pg.sql
--- old/MirrorCache-1.060/lib/MirrorCache/resources/migrations/Pg.sql   
2023-06-15 07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/resources/migrations/Pg.sql   
2023-07-20 08:47:03.000000000 +0200
@@ -368,11 +368,11 @@
     bytes      bigint,
     primary key(period, dt, project_id, country, mirror_id, file_type, os_id, 
os_version, arch_id, meta_id)
 );
--- 28
+-- 28 up
 -- do nothing
--- 29
+-- 29 up
 alter table hash add column if not exists sha512 varchar(128);
--- 30
+-- 30 up
 alter table report_body add column if not exists tag varchar(16);
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.060/lib/MirrorCache/resources/migrations/mysql.sql 
new/MirrorCache-1.061/lib/MirrorCache/resources/migrations/mysql.sql
--- old/MirrorCache-1.060/lib/MirrorCache/resources/migrations/mysql.sql        
2023-06-15 07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/lib/MirrorCache/resources/migrations/mysql.sql        
2023-07-20 08:47:03.000000000 +0200
@@ -373,5 +373,5 @@
 update popular_os set version = '\\3' where version = '\3';
 -- 29 up
 alter table hash add column if not exists sha512 varchar(128);
--- 30
+-- 30 up
 alter table report_body add column if not exists tag varchar(16);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.060/t/environ/14-project-hq.sh 
new/MirrorCache-1.061/t/environ/14-project-hq.sh
--- old/MirrorCache-1.060/t/environ/14-project-hq.sh    2023-06-15 
07:52:04.000000000 +0200
+++ new/MirrorCache-1.061/t/environ/14-project-hq.sh    2023-07-20 
08:47:03.000000000 +0200
@@ -103,7 +103,7 @@
 
 
 # all countries present in report
-$mc9/curl -s /rest/repmirror \
+$mc9/curl /rest/repmirror \
           | grep '"country":"br"' \
           | grep '"country":"de"' \
           | grep '"country":"dk"' \
@@ -112,13 +112,22 @@
           | grep '"country":"jp"' \
           | grep -F '"region":"na (http:\/\/127.0.0.1:3160)"'
 
-echo collect report when one of instances is down
+allmirrorspattern="$(ap1/print_address)"
+for i in {2..8}; do
+    x=ap$i
+    allmirrorspattern="$allmirrorspattern|$($x/print_address)"
+done
+
+# all mirrors are mentioned in html report
+test 8 == $($mc9/curl -i /report/mirrors | grep -A500 '200 OK' | grep -Eo 
$allmirrorspattern | sort | uniq | wc -l)
+
+echo collect report when one of the instances is down
 $mc6/stop
 
 $mc9/backstage/job -e report -a '["once"]'
 $mc9/backstage/shoot
 
-$mc9/curl -s /rest/repmirror \
+$mc9/curl /rest/repmirror \
           | grep '"country":"br"' \
           | grep '"country":"de"' \
           | grep '"country":"dk"' \
@@ -127,10 +136,13 @@
           | grep '"country":"jp"' \
           | grep -F '"region":"na (http:\/\/127.0.0.1:3160)"'
 
+# all mirrors are mentioned in html report
+test 8 == $($mc9/curl -i /report/mirrors | grep -A500 '200 OK' | grep -Eo 
$allmirrorspattern | sort | uniq | wc -l)
+
 echo also when the main db is down
 $mc9/db/stop
 
-$mc9/curl -s /rest/repmirror \
+$mc9/curl /rest/repmirror \
           | grep '"country":"br"' \
           | grep '"country":"de"' \
           | grep '"country":"dk"' \
@@ -139,4 +151,7 @@
           | grep '"country":"jp"' \
           | grep -F '"region":"na (http:\/\/127.0.0.1:3160)"'
 
+# all mirrors are mentioned in html report
+test 8 == $($mc9/curl -i /report/mirrors | grep -A500 '200 OK' | grep -Eo 
$allmirrorspattern | sort | uniq | wc -l)
+
 echo success

++++++ MirrorCache.obsinfo ++++++
--- /var/tmp/diff_new_pack.LiksZD/_old  2023-07-27 16:53:21.202676987 +0200
+++ /var/tmp/diff_new_pack.LiksZD/_new  2023-07-27 16:53:21.206677010 +0200
@@ -1,5 +1,5 @@
 name: MirrorCache
-version: 1.060
-mtime: 1686808324
-commit: dcff388396882b5014fc4db8e263df183647b6ef
+version: 1.061
+mtime: 1689835623
+commit: ccac89f907703f26b57e8f2d2068d94cf4e41601
 

Reply via email to