Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package MirrorCache for openSUSE:Factory 
checked in at 2022-05-26 18:44:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/MirrorCache (Old)
 and      /work/SRC/openSUSE:Factory/.MirrorCache.new.2254 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "MirrorCache"

Thu May 26 18:44:03 2022 rev:14 rq:979295 version:1.033

Changes:
--------
--- /work/SRC/openSUSE:Factory/MirrorCache/MirrorCache.changes  2022-05-12 
23:01:10.920862994 +0200
+++ /work/SRC/openSUSE:Factory/.MirrorCache.new.2254/MirrorCache.changes        
2022-05-26 18:44:10.645186177 +0200
@@ -1,0 +2,20 @@
+Thu May 19 07:14:05 UTC 2022 - Andrii Nikitin <andrii.niki...@suse.com>
+
+- Update to version 1.033:
+  * Add various patterns for files for which mirrors shouldnt be used (#275)
+  * Fix regexp in latest_misses sql so *-primary.xml wasnt requesting scans 
(#275)
+  * Add MyMirrors menu to openSUSE branding (#275)
+  * Introduce MIRRORCACHE_VPN variable which has higher priority thant 
MIRRORCACHE_VPN_PREFIX (#275)
+  * Allow regular users add and manage own mirrors (#274)
+  * Add parameter MIRRORCACHE_MAX_PATH (#274)
+
+-------------------------------------------------------------------
+Thu May 12 07:31:11 UTC 2022 - Andrii Nikitin <andrii.niki...@suse.com>
+
+- Update to version 1.032:
+  * Set MIME type when rendering files (#273)
+  * Optimize main sql query so it doesnt create tmp disk tables in mariadb 
(#272)
+  * Force sql plan in job mirror_check_from_stat for mariadb (#272)
+  * Add shared guard to schedule jobs to avoid deadlocks in DB (#272)
+
+-------------------------------------------------------------------

Old:
----
  MirrorCache-1.031.obscpio

New:
----
  MirrorCache-1.033.obscpio

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

Other differences:
------------------
++++++ MirrorCache.spec ++++++
--- /var/tmp/diff_new_pack.kBRusO/_old  2022-05-26 18:44:11.693187400 +0200
+++ /var/tmp/diff_new_pack.kBRusO/_new  2022-05-26 18:44:11.701187410 +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)
 %define build_requires %{assetpack_requires} rubygem(sass) tidy sysuser-shadow 
sysuser-tools
 Name:           MirrorCache
-Version:        1.031
+Version:        1.033
 Release:        0
 Summary:        WebApp to redirect and manage mirrors
 License:        GPL-2.0-or-later

++++++ MirrorCache-1.031.obscpio -> MirrorCache-1.033.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/assets/javascripts/admintable.js 
new/MirrorCache-1.033/assets/javascripts/admintable.js
--- old/MirrorCache-1.031/assets/javascripts/admintable.js      2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/assets/javascripts/admintable.js      2022-05-18 
14:28:29.000000000 +0200
@@ -297,7 +297,7 @@
     if (isEditingAdminTableRow(meta)) {
         return renderEditableAdminTableActions(data, type, row, meta);
     }
-    if (!window.isAdmin) {
+    if (!window.editable) {
         return '';
     }
     var url = $("#admintable_api_url").val();
@@ -313,7 +313,7 @@
     if (type !== 'display') {
         return data ? data : newRowId;
     }
-    if (!window.isAdmin) {
+    if (!window.editable) {
         return '';
     }
     if (data) {
@@ -327,7 +327,7 @@
     }
 }
 
-function setupAdminTable(isAdmin) {
+function setupAdminTable(editable) {
     // adjust sorting so empty strings come last
     jQuery.extend(jQuery.fn.dataTableExt.oSort, {
         'empty-string-last-asc': function(str1, str2) {
@@ -447,7 +447,7 @@
     });
 
     // set/update page-global state (there can only be one admin table at a 
page anyways)
-    window.isAdmin = isAdmin;
+    window.editable = editable;
     window.adminTable = dataTable;
 
     // prevent sorting when help popover on table heading is clicked
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/lib/MirrorCache/Datamodule.pm 
new/MirrorCache-1.033/lib/MirrorCache/Datamodule.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Datamodule.pm 2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Datamodule.pm 2022-05-18 
14:28:29.000000000 +0200
@@ -19,6 +19,7 @@
 use Mojo::URL;
 use Time::HiRes qw(time);
 use Digest::SHA qw(sha1_hex);
+use Mojolicious::Types;
 use MirrorCache::Utils 'region_for_country';
 
 has c => undef, weak => 1;
@@ -46,9 +47,13 @@
 
 has root_subtree => ($ENV{MIRRORCACHE_SUBTREE} // "");
 
+has _vpn_var => $ENV{MIRRORCACHE_VPN};
 has vpn_prefix => ($ENV{MIRRORCACHE_VPN_PREFIX} ? 
lc($ENV{MIRRORCACHE_VPN_PREFIX}) : "10.");
 
 has 'at';
+has '_mime';
+
+my $TYPES = Mojolicious::Types->new;
 
 sub elapsed($self) {
     return abs(time - $self->at);
@@ -85,6 +90,8 @@
 }
 
 sub vpn($self) {
+    return $self->_vpn_var if defined $self->_vpn_var;
+
     unless (defined $self->_vpn) {
         my $ip = $self->ip;
         $ip =~ s/^::ffff://;
@@ -197,6 +204,13 @@
     return $self->_original_path;
 }
 
+sub mime($self) {
+    unless (defined $self->_mime) {
+        $self->_init_path;
+    }
+    return $self->_mime;
+}
+
 sub our_path($self, $path) {
     return 1 if 0 eq rindex($path, $self->_route, 0);
     return 0;
@@ -397,8 +411,12 @@
         if !$self->mirrorlist
         && ( !$self->metalink || $self->metalink_accept )
         && !$self->zsync
-        && $path =~ 
m/.*\/(repodata\/repomd.xml[^\/]*|media\.1\/media|.*\.sha256(\.asc)|Release(.key|.gpg)?|InRelease|Packages(.gz)?|Sources(.gz)?|.*_Arch\.(files|db|key)(\.(sig|tar\.gz(\.sig)?))?|(files|primary|other).xml.gz)$/;
+        && $path =~ 
m/.*\/(repodata\/repomd.xml[^\/]*|media\.1\/media|.*\.sha256(\.asc)|Release(.key|.gpg)?|InRelease|Packages(.gz)?|Sources(.gz)?|.*_Arch\.(files|db|key)(\.(sig|tar\.gz(\.sig)?))?|(files|primary|other).xml.gz|[Pp]ackages(\.[A-Z][A-Z])?\.(xz|gz)|gpg-pubkey.*\.asc|CHECKSUMS)$/;
 
+    my ($ext) = $path =~ /([^.]+)$/;
+    my $mime = '';
+    $mime = $TYPES->type($ext) // '' if $ext;
+    $self->_mime($mime);
     $self->_path($path);
     $self->_trailing_slash($trailing_slash);
     $self->agent; # parse headers
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/MyServer.pm 
new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/MyServer.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/MyServer.pm     
1970-01-01 01:00:00.000000000 +0100
+++ new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/MyServer.pm     
2022-05-18 14:28:29.000000000 +0200
@@ -0,0 +1,45 @@
+use utf8;
+package MirrorCache::Schema::Result::MyServer;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table("server");
+
+__PACKAGE__->add_columns(
+  "id",
+  {
+    data_type         => "integer",
+    is_auto_increment => 1,
+    is_nullable       => 0,
+    sequence          => "server_id_seq",
+  },
+  "hostname",
+  { data_type => "varchar", is_nullable => 0, size => 128 },
+  "urldir",
+  { data_type => "varchar", is_nullable => 0, size => 128 },
+  "enabled",
+  { data_type => "boolean", is_nullable => 0 },
+  "region",
+  { data_type => "varchar", is_nullable => 0, size => 2 },
+  "country",
+  { data_type => "varchar", is_nullable => 0, size => 2 },
+  "score",
+  { data_type => "smallint", is_nullable => 0 },
+  "comment",
+  { data_type => "text", is_nullable => 0 },
+  "public_notes",
+  { data_type => "varchar", is_nullable => 0, size => 512 },
+  "lat",
+  { data_type => "numeric", is_nullable => 1, size => [6, 3] },
+  "lng",
+  { data_type => "numeric", is_nullable => 1, size => [6, 3] },
+);
+
+__PACKAGE__->set_primary_key("id");
+
+# __PACKAGE__->has_many('id' => 'MirrorCache::Schema::Result::ServerAdmin');
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/Server.pm 
new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/Server.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/Server.pm       
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/Server.pm       
2022-05-18 14:28:29.000000000 +0200
@@ -148,10 +148,11 @@
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+__PACKAGE__->has_many(
+  "server_admin",
+  "MirrorCache::Schema::Result::ServerAdmin",
+  { "foreign.server_id" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
 
-# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-06-24 15:20:56
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DvsVDcPjSkk7dTGfP1c4uQ
-
-
-# You can replace this text with custom code or comments, and it will be 
preserved on regeneration
 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/ServerAdmin.pm 
new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/ServerAdmin.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Schema/Result/ServerAdmin.pm  
1970-01-01 01:00:00.000000000 +0100
+++ new/MirrorCache-1.033/lib/MirrorCache/Schema/Result/ServerAdmin.pm  
2022-05-18 14:28:29.000000000 +0200
@@ -0,0 +1,24 @@
+use utf8;
+package MirrorCache::Schema::Result::ServerAdmin;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table("server_admin");
+
+__PACKAGE__->add_columns(
+  "server_id",
+  {
+    data_type         => "integer",
+    is_nullable       => 0,
+  },
+  "username",
+  { data_type => "varchar", is_nullable => 0, size => 128 },
+);
+
+__PACKAGE__->set_primary_key("server_id", "username");
+# __PACKAGE__->has_one('server_id' => 'MirrorCache::Schema::Result::Server');
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Schema/ResultSet/Server.pm 
new/MirrorCache-1.033/lib/MirrorCache/Schema/ResultSet/Server.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Schema/ResultSet/Server.pm    
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Schema/ResultSet/Server.pm    
2022-05-18 14:28:29.000000000 +0200
@@ -20,6 +20,9 @@
 
 use base 'DBIx::Class::ResultSet';
 
+# MariaDB will create temporary disk table for each mirror_query if this is 
bigger than default
+my $MIRRORCACHE_MAX_PATH = int($ENV{MIRRORCACHE_MAX_PATH} // 512);
+
 sub mirrors_query {
     my (
         $self, $country, $region, $folder_id,       $file_id, $capability,
@@ -92,7 +95,7 @@
 
     my $sql = <<"END_SQL";
 select * from (
-select x.id as mirror_id, concat(case when support_scheme > 0 then 
'$capability' else '$capabilityx' end, '://', uri) as url,
+select x.id as mirror_id, left(concat(case when support_scheme > 0 then 
'$capability' else '$capabilityx' end, '://', uri),$MIRRORCACHE_MAX_PATH) as 
url,
 dist,
 case $weight_country_case when region $avoid_region= '$region' then 1 else 0 
end rating_country,
 score, country, region, lng,
@@ -116,7 +119,7 @@
 CASE WHEN COALESCE(stability_ipv.rating, 0)    > 0 THEN 1 ELSE 0 END AS 
support_ipv,
 CASE WHEN COALESCE(stability_ipv.rating, 0)    > 0 THEN stability_ipv.rating   
 WHEN COALESCE(stability_ipvx.rating, 0)    > 0 THEN stability_ipvx.rating    
ELSE 0 END AS rating_ipv
 from (
-    select s.*, fl.name
+    select s.id, s.hostname, s.hostname_vpn, s.urldir, s.region, s.country, 
s.lat, s.lng, s.score, fl.name
     from folder_diff fd
     join file fl on fl.id = ?
     join folder_diff_server fds on fd.id = fds.folder_diff_id and 
date_trunc('second', fl.dt) <= fds.dt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Schema/ResultSet/Stat.pm 
new/MirrorCache-1.033/lib/MirrorCache/Schema/ResultSet/Stat.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Schema/ResultSet/Stat.pm      
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Schema/ResultSet/Stat.pm      
2022-05-18 14:28:29.000000000 +0200
@@ -144,9 +144,13 @@
        limit 1
 END_SQL
     $sql =~ s/E'/'/g unless $dbh->{Driver}->{Name} eq 'Pg';
+    $sql =~ s/join server/straight_join server/g unless $dbh->{Driver}->{Name} 
eq 'Pg';
 
     my $prep = $dbh->prepare($sql);
+    local $SIG{ALRM} = sub { die "TIMEOUT in latest_hit\n" };
+    alarm(10);
     $prep->execute();
+    alarm(0);
     return $dbh->selectrow_array($prep);
 };
 
@@ -164,7 +168,7 @@
 where mirror_id < 1
 and ( mirror_id in (0,-1) or mirrorlist )
 and file_id is null
-and stat.path !~ 
'.*\/(repodata\/repomd.xml[^\/]*|media\.1\/media|.*\.sha256(\.asc)|Release(.key|.gpg)?|InRelease|Packages(.gz)?|Sources(.gz)?)|.*_Arch\.(files|db|key)(\.(sig|tar\.gz(\.sig)?))?|(files|primary|other).xml.gz$'
+and stat.path !~ 
'.*\/(repodata\/repomd.xml[^\/]*|media\.1\/media|.*\.sha256(\.asc)|Release(.key|.gpg)?|InRelease|Packages(.gz)?|Sources(.gz)?|.*_Arch\.(files|db|key)(\.(sig|tar\.gz(\.sig)?))?|(files|primary|other).xml.gz|[Pp]ackages(\.[A-Z][A-Z])?\.(xz|gz)|gpg-pubkey.*\.asc|CHECKSUMS)$'
 and lower(stat.agent) NOT LIKE '%bot%'
 and lower(stat.agent) NOT LIKE '%rclone%'
 and (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Task/FolderSyncSchedule.pm 
new/MirrorCache-1.033/lib/MirrorCache/Task/FolderSyncSchedule.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Task/FolderSyncSchedule.pm    
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Task/FolderSyncSchedule.pm    
2022-05-18 14:28:29.000000000 +0200
@@ -44,6 +44,15 @@
 
     # retry later if many folder_sync jobs are scheduled according to 
estimation
     return $job->retry({delay => 30}) if 
$app->backstage->inactive_jobs_exceed_limit(100, 'folder_sync');
+    my $schedule_guard;
+    unless ($schedule_guard = $minion->guard('schedule_folder', 60)) {
+        sleep 1;
+        unless ($schedule_guard = $minion->guard('schedule_folder', 60)) {
+            $job->note(sharedlock => 'Retrying');
+            return $job->retry({delay => 1});
+        }
+    }
+    $job->note(sharedlock => 'Got it');
 
     my @folders;
 if ($schema->pg) {
@@ -78,7 +87,7 @@
         ) x ON x.id = f.id
         set f.sync_requested = CURRENT_TIMESTAMP(3)"
     )->execute();
-    
+
     @folders = $schema->resultset('Folder')->search({
         sync_requested => { '>', \"COALESCE(sync_scheduled, 
date_sub(sync_requested, interval 1 second))" }
     }, {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/Task/MirrorScanSchedule.pm 
new/MirrorCache-1.033/lib/MirrorCache/Task/MirrorScanSchedule.pm
--- old/MirrorCache-1.031/lib/MirrorCache/Task/MirrorScanSchedule.pm    
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/Task/MirrorScanSchedule.pm    
2022-05-18 14:28:29.000000000 +0200
@@ -23,6 +23,7 @@
 
 my $RESCAN = int($ENV{MIRRORCACHE_RESCAN_INTERVAL} // 24 * 60 * 60);
 my $DELAY  = int($ENV{MIRRORCACHE_SCHEDULE_RETRY_INTERVAL} // 10);
+$DELAY     = $DELAY+1 if $DELAY; # period should differ from the same in 
FolderScanSchedule to avoid deadlocks
 my $EXPIRE = int($ENV{MIRRORCACHE_SCHEDULE_EXPIRE_INTERVAL} // 14 * 24 * 60 * 
60);
 my $RECKLESS=int($ENV{MIRRORCACHE_RECKLESS} // 0);
 
@@ -42,6 +43,16 @@
 
     # retry later if many jobs are scheduled according to estimation
     return $job->retry({delay => 30}) if 
$app->backstage->inactive_jobs_exceed_limit(100, 'mirror_scan');
+    my $schedule_guard;
+    unless ($schedule_guard = $minion->guard('schedule_folder', 60)) {
+        sleep 1;
+        unless ($schedule_guard = $minion->guard('schedule_folder', 60)) {
+            $job->note(sharedlock => 'Retrying');
+            return $job->retry({delay => 1});
+        }
+    }
+    $job->note(sharedlock => 'Got it');
+
 
     my @folders;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm     
1970-01-01 01:00:00.000000000 +0100
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm     
2022-05-18 14:28:29.000000000 +0200
@@ -0,0 +1,41 @@
+# Copyright (C) 2022 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::Controller::App::Myserver;
+use Mojo::Base 'MirrorCache::WebAPI::Controller::App::Table';
+
+sub index {
+    shift->SUPER::admintable('myserver');
+}
+
+sub update {
+    my ($self) = @_;
+    my $set  = $self->schema->resultset('Server');
+
+    my $id = $self->param('id');
+
+    my $mirror = $set->find($id);
+    if (!$mirror) {
+        $self->flash('error', "Can't find mirror {$id}");
+    }
+    else {
+        $self->flash('info', 'Mirror ' . $mirror->hostname . ' updated');
+        $self->emit_event('mc_mirror_updated', {hostname => 
$mirror->hostname});
+    }
+
+    $self->redirect_to($self->url_for('myserver'));
+}
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Controller/Rest/Table.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Controller/Rest/Table.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Controller/Rest/Table.pm       
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Controller/Rest/Table.pm       
2022-05-18 14:28:29.000000000 +0200
@@ -26,7 +26,13 @@
         keys     => [['id'], ['hostname'],],
         cols     => ['id', 'hostname', 'urldir', 'enabled', 'region', 
'country', 'comment', 'public notes'],
         required => ['id', 'hostname', 'urldir'],
-        defaults => {urldir => '/'},
+        defaults => {urldir => ''},
+    },
+    MyServer => {
+        keys     => [['id'], ['hostname'],],
+        cols     => ['id', 'hostname', 'urldir', 'enabled', 'region', 
'country', 'comment', 'public notes'],
+        required => ['id', 'hostname', 'urldir'],
+        defaults => {urldir => ''},
     },
     Folder => {
         keys     => [['id'], ['path'],],
@@ -34,6 +40,12 @@
     },
 );
 
+sub _myserver {
+    my ($req) = @_;
+    return 1 if $req->url->to_string =~ 'myserver';
+    return 0;
+}
+
 sub list {
     my ($self) = @_;
 
@@ -54,11 +66,23 @@
 
     my @result;
     eval {
-        my $rs = $self->schema->resultset($table);
-        @result = %search ? $rs->search(\%search) : $rs->all;
+        unless (_myserver($self->req)) {
+            my $rs = $self->schema->resultset($table);
+            @result = %search ? $rs->search(\%search) : $rs->all;
+        } else {
+            my $rs = $self->schema->resultset('Server');
+            $search{username} = $self->current_username;
+            @result = %search ? $rs->search(
+                \%search,
+                {
+                    join => 'server_admin',
+                }
+            ) : $rs->all;
+        }
     };
     my $error = $@;
     if ($error) {
+        print STDERR "RESP1 : " . $error . "\n";
         return $self->render(json => {error => $error}, status => 404);
     }
 
@@ -85,10 +109,11 @@
 sub create {
     my ($self) = @_;
 
-    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $self->current_user;
+    my $username = $self->current_username;
+    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $username;
 
     my $table  = $self->param("table");
-    
+
     my %entry  = %{$tables{$table}->{defaults}};
     my $prepare_error = $self->_prepare_params($table, \%entry);
     return $self->render(json => {error => $prepare_error}, status => 400) if 
defined $prepare_error;
@@ -101,6 +126,8 @@
     if ($error) {
         return $self->render(json => {error => $error}, status => 400);
     }
+    try { $self->schema->resultset('ServerAdmin')->create({server_id => $id, 
username => $username}); } catch { $error = shift; } if _myserver($self->req);
+
     my %event_data;
     for my $k (keys %entry) {
         next if !$entry{$k} or "$entry{$k}" eq '';
@@ -108,18 +135,27 @@
     }
     my $name = 'mc_' . lc $table . '_create';
     $self->emit_event($name, \%event_data, $self->current_user->id);
+    if ($error) {
+        return $self->render(json => {error => $error}, status => 400);
+    }
     $self->render(json => {id => $id});
 }
 
 sub update {
     my ($self) = @_;
 
-    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $self->current_user;
+    my $username = $self->current_username;
+    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $username;
+
+    if (_myserver($self->req)) {
+        my $rc = $self->schema->resultset('ServerAdmin')->find({server_id => 
$self->param('id'), username => $username});
+        return $self->render(json => {error => 'Could not find admin entry for 
server.'}, status => 404) unless $rc && $rc->username eq $username;
+    }
 
     my $table = $self->param("table");
 
     my $entry = {};
-    my $prepare_error = $self->_prepare_params($table, $entry);
+    my $prepare_error = $self->_prepare_params($table, $entry, $username);
     return $self->render(json => {error => $prepare_error}, status => 400) if 
defined $prepare_error;
 
     my $schema = $self->schema;
@@ -181,7 +217,13 @@
 sub destroy {
     my ($self) = @_;
 
-    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $self->current_user;
+    my $username = $self->current_username;
+    return $self->render(json => {error => 'Could not identify current user 
(you).'}, status => 400) unless $username;
+
+    if (_myserver($self->req)) {
+        my $rc = $self->schema->resultset('ServerAdmin')->find({server_id => 
$self->param('id'), username => $username});
+        return $self->render(json => {error => 'Could not find admin entry for 
server.'}, status => 404) unless $rc && $rc->username eq $username;
+    }
 
     my $table    = $self->param("table");
     my $schema   = $self->schema;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/AuditLog.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/AuditLog.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/AuditLog.pm     
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/AuditLog.pm     
2022-05-18 14:28:29.000000000 +0200
@@ -27,7 +27,7 @@
 # mirror_country_miss means that request was served by a mirror in region
 my @error_events = qw(mirror_scan_error mirror_path_error mirror_error 
mirror_country_miss);
 my @other_events = qw(unknown_ip debug);
-my @user_events = qw(user_update user_delete server_create server_update 
server_delete);
+my @user_events = qw(user_update user_delete server_create server_update 
server_delete myserver_create myserver_update myserver_delete);
 
 sub register {
     my ($self, $app) = @_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/Dir.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/Dir.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/Dir.pm  2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/Dir.pm  2022-05-18 
14:28:29.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2020,2020 SUSE LLC
+# Copyright (C) 2020-2022 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
@@ -23,7 +23,6 @@
 use Time::Piece;
 use Time::Seconds;
 use Time::ParseDate;
-use Mojolicious::Types;
 use MirrorCache::Utils;
 use MirrorCache::Datamodule;
 
@@ -381,12 +380,6 @@
    versioncmp(lc($a->{name}), lc($b->{name}));
 }
 
-sub _get_ext {
-    $_[0] =~ /\.([0-9a-zA-Z]+)$/ || return;
-    return lc $1;
-}
-my $types = Mojolicious::Types->new;
-
 sub _render_dir_from_db {
     my $dm  = shift;
     my $id  = shift;
@@ -414,7 +407,7 @@
 
         my $is_dir    = '/' eq substr($basename, -1)? 1 : 0;
         my $encoded   = Encode::decode_utf8( './' . $basename );
-        my $mime_type = $types->type( _get_ext($basename) || 'txt' ) || 
'text/plain';
+        my $mime_type = $dm->mime || 'text/plain';
 
         push @files, {
             url   => $encoded,
@@ -462,7 +455,7 @@
 
         my $is_dir    = '/' eq substr($basename, -1)? 1 : 0;
         my $encoded   = Encode::decode_utf8( './' . $basename );
-        my $mime_type = $types->type( _get_ext($basename) || 'txt' ) || 
'text/plain';
+        my $mime_type = $dm->mime || 'text/plain';
 
         push @files, {
             url   => $encoded,
@@ -494,7 +487,7 @@
     eval { $size = -s $full if -f $full; };
     return undef unless (defined $size) && $size <= $SMALL_FILE_SIZE;
     my $c = $dm->c;
-    $c->render_file(filepath => $full);
+    $c->render_file(filepath => $full, content_type => $dm->mime);
     return 1;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/Helpers.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/Helpers.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/Helpers.pm      
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/Helpers.pm      
2022-05-18 14:28:29.000000000 +0200
@@ -79,11 +79,13 @@
         });
 
     $app->helper(current_user     => \&_current_user);
+    $app->helper(current_username => \&_current_username);
     $app->helper(is_operator      => \&_is_operator);
     $app->helper(is_admin         => \&_is_admin);
     $app->helper(is_local_request => \&_is_local_request);
 
-    $app->helper(is_admin_js    => sub { 
Mojo::ByteStream->new(shift->helpers->is_admin    ? 'true' : 'false') });
+    $app->helper(is_admin_js         => sub { 
Mojo::ByteStream->new(shift->helpers->is_admin ? 'true' : 'false') });
+    $app->helper(current_username_js => sub { 
Mojo::ByteStream->new(shift->helpers->current_username) });
 
     $app->helper(
         # generate popover help button with title and content
@@ -168,6 +170,15 @@
     return $current_user && defined $current_user->{user} ? 
$current_user->{user} : undef;
 }
 
+sub _current_username {
+    my $c = shift;
+
+    return '' unless $c->current_user;
+    my $current_user = $c->stash('current_user');
+    return '' unless $current_user && $current_user->{user};
+    return $current_user->{user}->nickname;
+}
+
 sub _is_operator {
     my $c    = shift;
     my $user = shift || $c->current_user;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm    
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/RootLocal.pm    
2022-05-18 14:28:29.000000000 +0200
@@ -79,7 +79,7 @@
     if ($redirect) {
         $res = !!$c->redirect_to($redirect . $root_subtree . $filepath);
     } else {
-        $res = !!$c->render_file(filepath => $self->rootpath($filepath) . 
$root_subtree . $filepath);
+        $res = !!$c->render_file(filepath => $self->rootpath($filepath) . 
$root_subtree . $filepath, content_type => $dm->mime);
     }
     $c->stat->redirect_to_root($dm, $not_miss);
     return $res;
@@ -96,7 +96,7 @@
     eval { $size = -s $full if -f $full; };
     return undef unless ((defined $size) && $size <= $max_size);
     my $c = $dm->c;
-    $c->render_file(filepath => $full);
+    $c->render_file(filepath => $full, content_type => $dm->mime);
     return 1;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm   
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI/Plugin/RootRemote.pm   
2022-05-18 14:28:29.000000000 +0200
@@ -94,7 +94,7 @@
     my $c = $dm->c;
 
     if ($nfs && $dm->must_render_from_root && -f $nfs . $filepath) {
-        $c->render_file(filepath => $nfs . $filepath);
+        $c->render_file(filepath => $nfs . $filepath, content_type => 
$dm->mime);
         $c->stat->redirect_to_root($dm, $not_miss);
         return 1;
     }
@@ -111,7 +111,7 @@
     my $c = $dm->c;
 
     return undef unless($dm->must_render_from_root && -f $nfs . $filepath);
-    $c->render_file(filepath => $nfs . $filepath);
+    $c->render_file(filepath => $nfs . $filepath, content_type => $dm->mime);
     $c->stat->redirect_to_root($dm, 1);
     return 1;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/lib/MirrorCache/WebAPI.pm 
new/MirrorCache-1.033/lib/MirrorCache/WebAPI.pm
--- old/MirrorCache-1.031/lib/MirrorCache/WebAPI.pm     2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/WebAPI.pm     2022-05-18 
14:28:29.000000000 +0200
@@ -44,7 +44,7 @@
 
     $self->hook(before_command => sub {
         my ($command, $arg) = @_;
-        $self->_setup_webui if ref($command) =~ m/daemon|prefork/; 
+        $self->_setup_webui if ref($command) =~ m/daemon|prefork/;
     }) unless $started;
 
     $self;
@@ -172,6 +172,16 @@
     
$rest_operator_r->put('/server/location/:id')->name('rest_put_server_location')->to('server_location#update_location');
     
$rest_operator_r->post('/sync_tree')->name('rest_post_sync_tree')->to('folder_jobs#sync_tree');
 
+    $rest_r->get('/myserver')->name('rest_myserver')->to('table#list', table 
=> 'MyServer');
+    $rest_r->get('/myserver/:id')->to('table#list', table => 'MyServer');
+    my $rest_usr_auth;
+    $rest_usr_auth = $rest->under('/')->to('session#ensure_user');
+    my $rest_usr_r = $rest_usr_auth->any('/')->to(namespace => 
'MirrorCache::WebAPI::Controller::Rest');
+    $rest_usr_r->post('/myserver')->to('table#create', table => 'MyServer');
+    
$rest_usr_r->post('/myserver/:id')->name('post_myserver')->to('table#update', 
table => 'MyServer');
+    $rest_usr_r->delete('/myserver/:id')->to('table#destroy', table => 
'MyServer');
+    
$rest_usr_r->put('/myserver/location/:id')->name('rest_put_myserver_location')->to('myserver_location#update_location');
+
     $rest_r->get('/folder')->name('rest_folder')->to('table#list', table => 
'Folder');
 
     
$rest_r->get('/folder_jobs/:id')->name('rest_folder_jobs')->to('folder_jobs#list');
@@ -183,6 +193,7 @@
     my $app_r = $r->any('/app')->to(namespace => 
'MirrorCache::WebAPI::Controller::App');
 
     $app_r->get('/server')->name('server')->to('server#index');
+    $app_r->get('/myserver')->name('myserver')->to('myserver#index');
     $app_r->get('/folder')->name('folder')->to('folder#index');
     $app_r->get('/folder/<id:num>')->name('folder_show')->to('folder#show');
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/resources/migrations/Pg.sql 
new/MirrorCache-1.033/lib/MirrorCache/resources/migrations/Pg.sql
--- old/MirrorCache-1.031/lib/MirrorCache/resources/migrations/Pg.sql   
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/resources/migrations/Pg.sql   
2022-05-18 14:28:29.000000000 +0200
@@ -273,3 +273,10 @@
 -- 22 up
 create index if not exists folder_diff_file_2 on folder_diff_file(file_id, 
folder_diff_id);
 alter table server_capability_check drop column if exists success;
+-- 23 up
+create unique index acc_nickname_uk on acc(nickname);
+create table server_admin (
+    server_id int references server on delete cascade,
+    username varchar(64) not null,
+    primary key(server_id,username)
+);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/lib/MirrorCache/resources/migrations/mysql.sql 
new/MirrorCache-1.033/lib/MirrorCache/resources/migrations/mysql.sql
--- old/MirrorCache-1.031/lib/MirrorCache/resources/migrations/mysql.sql        
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/lib/MirrorCache/resources/migrations/mysql.sql        
2022-05-18 14:28:29.000000000 +0200
@@ -268,3 +268,11 @@
 -- 22 up
 create index if not exists folder_diff_file_2 on folder_diff_file(file_id, 
folder_diff_id);
 alter table server_capability_check drop column if exists success;
+-- 23 up
+create unique index acc_nickname_uk on acc(nickname);
+create table server_admin (
+    server_id int not null,
+    username varchar(64) not null,
+    primary key(server_id,username),
+    constraint `fk_server_admin` FOREIGN KEY(server_id) references server(id) 
on delete cascade
+);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/t/environ/01-smoke.sh 
new/MirrorCache-1.033/t/environ/01-smoke.sh
--- old/MirrorCache-1.031/t/environ/01-smoke.sh 2022-05-05 03:53:03.000000000 
+0200
+++ new/MirrorCache-1.033/t/environ/01-smoke.sh 2022-05-18 14:28:29.000000000 
+0200
@@ -44,9 +44,15 @@
 # check redirect is correct
 $mc/curl -Is /download/folder1 | grep -i 'Location: /download/folder1/'
 
+tmp_tables1="$(test "$MIRRORCACHE_DB_PROVIDER" != mariadb || $mc/sql 'show 
global status like '\''%tmp%disk%'\''')"
+
 # only ap7 is in US
 $mc/curl -Is /download/folder1/file1.1.dat | grep -C10 302 | grep 
"$($ap7/print_address)"
 
+tmp_tables2="$(test "$MIRRORCACHE_DB_PROVIDER" != mariadb || $mc/sql 'show 
global status like '\''%tmp%disk%'\''')"
+# test the main query doesn't create tmp tables on disk (relevant only for 
mariadb)
+test "$tmp_tables1" == "$tmp_tables2"
+
 ###################################
 # test files are removed properly
 rm $mc/dt/folder1/file1.1.dat
@@ -108,3 +114,4 @@
 
 $mc/sql 'select * from stat_agg'
 $mc/curl /rest/stat | grep 
'"hour":{"bot":2,"hit":24,"miss":6,"prev_bot":2,"prev_hit":24,"prev_miss":6}'
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/t/environ/03-headquarter-subsidiaries.sh 
new/MirrorCache-1.033/t/environ/03-headquarter-subsidiaries.sh
--- old/MirrorCache-1.031/t/environ/03-headquarter-subsidiaries.sh      
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/t/environ/03-headquarter-subsidiaries.sh      
2022-05-18 14:28:29.000000000 +0200
@@ -14,6 +14,7 @@
     mkdir -p $x/dt/{folder1,folder2,folder3}
     echo -n 1234 > $x/dt/folder1/filebig1.1.dat
     echo -n 123  > $x/dt/folder1/filesmall1.1.dat
+    echo '[]'    > $x/dt/folder1/file.json
     eval mc$i=$x
 done
 
@@ -73,3 +74,8 @@
 echo check small files are not redirected
 curl --interface $na_interface -Is 
http://$hq_address/download/folder1/filebig1.1.dat | grep "Location: 
http://$na_address/download/folder1/filebig1.1.dat";
 curl --interface $na_interface -Is 
http://$hq_address/download/folder1/filesmall1.1.dat | grep "200 OK"
+
+ct=$($mc9/curl -I /download/folder1/file.json | grep Content-Type)
+[[ "$ct" =~ application/json ]]
+ct=$($mc9/curl -I /folder1/file.json | grep Content-Type)
+[[ "$ct" =~ application/json ]]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/t/environ/04-remote-down.sh 
new/MirrorCache-1.033/t/environ/04-remote-down.sh
--- old/MirrorCache-1.031/t/environ/04-remote-down.sh   2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/t/environ/04-remote-down.sh   2022-05-18 
14:28:29.000000000 +0200
@@ -15,6 +15,8 @@
     mkdir -p $x/dt/{folder1,folder2,folder3}/repodata
     echo $x/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 
touch
     echo $x/dt/{folder1,folder2,folder3}/repodata/repomd.xml   | xargs -n 1 
touch
+    echo $x/dt/{folder1,folder2,folder3}/repodata/primary.xml.gz        | 
xargs -n 1 touch
+    echo $x/dt/{folder1,folder2,folder3}/repodata/abc-primary.xml.gz    | 
xargs -n 1 touch
     touch $x/dt/folder3/Packages.gz
     $x/start
 done
@@ -27,10 +29,13 @@
 
 # remove folder1/file1.1.dt from ap8
 rm $ap8/dt/folder1/file2.1.dat
+rm $ap7/dt/folder1/repodata/abc-primary.xml.gz
 
 # first request redirected to root
 $mc/curl -I /download/folder1/repodata/repomd.xml | grep $($ap9/print_address)
 $mc/curl -I /download/folder1/file2.1.dat | grep $($ap9/print_address)
+$mc/curl -I /download/folder1/repodata/primary.xml.gz | grep 
$($ap9/print_address)
+$mc/curl -I /download/folder1/repodata/abc-primary.xml.gz | grep 
$($ap9/print_address)
 
 $mc/backstage/job folder_sync_schedule_from_misses
 $mc/backstage/job folder_sync_schedule
@@ -42,6 +47,9 @@
 $mc/curl -I /download/folder1/file2.1.dat | grep $($ap7/print_address)
 echo repomd is still taken from the root
 $mc/curl -I /download/folder1/repodata/repomd.xml | grep $($ap9/print_address)
+$mc/curl -I /download/folder1/repodata/primary.xml.gz | grep 
$($ap9/print_address)
+echo abc-primary.xml.gz is redirected though
+$mc/curl -I /download/folder1/repodata/abc-primary.xml.gz | grep 
$($ap8/print_address)
 
 # shutdown root
 $ap9/stop
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MirrorCache-1.031/t/environ/07-async-recurs.sh 
new/MirrorCache-1.033/t/environ/07-async-recurs.sh
--- old/MirrorCache-1.031/t/environ/07-async-recurs.sh  2022-05-05 
03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/t/environ/07-async-recurs.sh  2022-05-18 
14:28:29.000000000 +0200
@@ -3,7 +3,8 @@
 
 mc=$(environ mc $(pwd))
 
-MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=1
+MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=3
+
 $mc/gen_env 
MIRRORCACHE_SCHEDULE_RETRY_INTERVAL=$MIRRORCACHE_SCHEDULE_RETRY_INTERVAL \
             MIRRORCACHE_BACKSTAGE_WORKERS=15 \
             MIRRORCACHE_RECKLESS=0
@@ -31,8 +32,8 @@
 $mc/backstage/job -e folder_tree -a '["/folder1"]'
 $mc/backstage/job -e folder_tree -a '["/folder2"]'
 $mc/backstage/job folder_sync_schedule
-$mc/backstage/job mirror_scan_schedule
 $mc/backstage/start
+$mc/backstage/job mirror_scan_schedule
 
 $mc/curl -I /download/folder1/file1.1.dat | grep 302 \
    || ( sleep 1 ; $mc/curl -I /download/folder1/file1.1.dat | grep 302 ) \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/t/environ/15-local-symlink-subtree-rootredirect-vpn.sh 
new/MirrorCache-1.033/t/environ/15-local-symlink-subtree-rootredirect-vpn.sh
--- 
old/MirrorCache-1.031/t/environ/15-local-symlink-subtree-rootredirect-vpn.sh    
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/MirrorCache-1.033/t/environ/15-local-symlink-subtree-rootredirect-vpn.sh    
    2022-05-18 14:28:29.000000000 +0200
@@ -0,0 +1,86 @@
+#!lib/test-in-container-environ.sh
+set -ex
+
+mc=$(environ mc $(pwd))
+$mc/gen_env MIRRORCACHE_ROOT_COUNTRY=us \
+            MIRROCACHE_VPN=1
+$mc/start
+$mc/status
+
+ap8=$(environ ap8)
+ap7=$(environ ap7)
+
+mkdir -p $mc/dt/{folder1,folder2,folder3}
+echo $mc/dt/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch
+
+mkdir -p $mc/dt/updates/tool
+(
+cd $mc/dt/updates/tool/
+ln -s ../../folder1 v1
+ln -s ../../folder2 v2
+)
+
+ls -la $mc/dt/updates/tool/
+
+cp -r $mc/dt/folder1/ $ap7/dt/
+cp -r $mc/dt/folder2/ $ap7/dt/
+mkdir -p $ap8/dt/updates/tool/v1
+mkdir -p $ap8/dt/updates/tool/v2
+cp $mc/dt/folder1/* $ap8/dt/updates/tool/v1/
+cp $mc/dt/folder2/* $ap8/dt/updates/tool/v2/
+
+
+$ap7/start
+$ap7/curl /folder1/ | grep file1.1.dat
+
+$ap8/start
+$ap8/curl /updates/tool/v1/ | grep file1.1.dat
+
+
+$mc/sql "insert into 
server(hostname,hostname_vpn,urldir,enabled,country,region) select 
'notexists.mirror1.cc','$($ap7/print_address)','','t','us','na'"
+$mc/sql "insert into 
server(hostname,hostname_vpn,urldir,enabled,country,region) select 
'notexists.mirror2.cc','$($ap8/print_address)','','t','de','eu'"
+
+mcsub=$mc/sub
+
+$mcsub/gen_env MIRRORCACHE_ROOT="'$mc/dt:testhost.com'" \
+               MIRRORCACHE_SUBTREE=/updates \
+               MIRRORCACHE_TOP_FOLDERS=tool \
+               MIRRORCACHE_VPN=0 \
+               MIRRORCACHE_VPN_PREFIX=127.0.0. \
+               MIRRORCACHE_ROOT_COUNTRY=us
+$mcsub/start
+
+$mc/curl -Is /download/updates/tool/v1/file1.1.dat.mirrorlist
+$mc/curl -Is --interface 127.0.0.15 
/download/updates/tool/v2/file1.1.dat.mirrorlist
+
+$mc/backstage/job folder_sync_schedule_from_misses
+$mc/backstage/job folder_sync_schedule
+$mc/backstage/shoot
+$mc/backstage/job mirror_scan_schedule
+$mc/backstage/shoot
+
+$mcsub/curl /tool/v1/file1.1.dat.metalink   | grep -C10 
notexists.mirror1.cc/folder1/file1.1.dat | grep -C10 
notexists.mirror2.cc/updates/tool/v1/file1.1.dat | grep 
testhost.com/updates/tool/v1/file1.1.dat
+
+rc=0
+$mcsub/curl /tool/v1/file1.1.dat.metalink   | grep $($ap7/print_address) || 
rc=$?
+test $rc -gt 0
+rc=0
+$mcsub/curl /tool/v1/file1.1.dat.metalink   | grep $($ap8/print_address) || 
rc=$?
+test $rc -gt 0
+
+$mcsub/curl /tool/v2/file1.1.dat.metalink | grep -C20 
notexists.mirror2.cc/updates/tool/v2/file1.1.dat | grep 
testhost.com/updates/tool/v2/file1.1.dat
+
+
+$mcsub/curl /tool/v1/file1.1.dat.mirrorlist   | grep -C20 
notexists.mirror1.cc/folder1/file1.1.dat | grep -C20 
notexists.mirror2.cc/updates/tool/v1/file1.1.dat | grep 
testhost.com/updates/tool/v1/file1.1.dat
+
+rc=0
+$mcsub/curl /tool/v1/file1.1.dat.mirrorlist   | grep $($ap7/print_address) || 
rc=$?
+test $rc -gt 0
+rc=0
+$mcsub/curl /tool/v1/file1.1.dat.mirrorlist   | grep $($ap8/print_address) || 
rc=$?
+test $rc -gt 0
+
+$mcsub/curl /tool/v2/file1.1.dat.mirrorlist | grep -C20 
notexists.mirror2.cc/updates/tool/v2/file1.1.dat | grep 
testhost.com/updates/tool/v2/file1.1.dat
+
+# test request from ROOT_COUNTRY is just served
+$mc/curl -i /download/folder1/file1.1.dat?COUNTRY=us | grep '200 OK'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/templates/app/myserver/index.html.ep 
new/MirrorCache-1.033/templates/app/myserver/index.html.ep
--- old/MirrorCache-1.031/templates/app/myserver/index.html.ep  1970-01-01 
01:00:00.000000000 +0100
+++ new/MirrorCache-1.033/templates/app/myserver/index.html.ep  2022-05-18 
14:28:29.000000000 +0200
@@ -0,0 +1,38 @@
+% layout 'bootstrap';
+% title 'My Mirrors';
+
+% content_for 'ready_function' => begin
+    setupAdminTable('<%=current_username_js%>');
+% end
+
+<div class="row">
+    <div class="col-sm-12">
+        <h2><%= title %></h2>
+
+        %= include 'layouts/info'
+
+        <table id="myservers" class="admintable table table-striped">
+            <thead>
+                <tr>
+                    <th class="col_value">Id</th>
+                    <th class="col_value">Hostname</th>
+                    <th class="col_value">Urldir</th>
+                    <th class="col_value">Region</th>
+                    <th class="col_value">Country</th>
+                    <th class="col_value">Comment</th>
+                    <th class="col_value">Public Notes</th>
+                    <th class="col_value">Enabled</th>
+                    <th class="col_action">Actions</th>
+                </tr>
+            </thead>
+            <tbody>
+            </tbody>
+        </table>
+        % if (current_user) {
+        <div class="text-center">
+            <input value="New mirror" onclick="addAdminTableRow();" 
type="button" class="btn btn-default"/>
+        </div>
+        % }
+        <input type="hidden" id="admintable_api_url" value="/rest/myserver"/>
+    </div>
+</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/templates/branding/default/header.html.ep 
new/MirrorCache-1.033/templates/branding/default/header.html.ep
--- old/MirrorCache-1.031/templates/branding/default/header.html.ep     
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/templates/branding/default/header.html.ep     
2022-05-18 14:28:29.000000000 +0200
@@ -30,6 +30,7 @@
                 <div class="dropdown-menu">
                   %= link_to 'My IP' => url_for('/rest/myip') => class => 
'dropdown-item'
                   %= link_to 'My Statistics' => url_for('/rest/mystat') => 
class => 'dropdown-item'
+                  %= link_to 'My Mirrors' => url_for('myserver') => class => 
'dropdown-item'
                   % if (is_operator) {
                   %= tag 'div' => class => 'dropdown-divider'
                   %= tag 'h3' => class => 'dropdown-header' => 'Operator menu'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/MirrorCache-1.031/templates/branding/openSUSE/header.html.ep 
new/MirrorCache-1.033/templates/branding/openSUSE/header.html.ep
--- old/MirrorCache-1.031/templates/branding/openSUSE/header.html.ep    
2022-05-05 03:53:03.000000000 +0200
+++ new/MirrorCache-1.033/templates/branding/openSUSE/header.html.ep    
2022-05-18 14:28:29.000000000 +0200
@@ -36,6 +36,7 @@
           % if (current_user) {
           %= link_to 'My IP' => url_for('/rest/myip') => class => 
'dropdown-item'
           %= link_to 'My Statistics' => url_for('/rest/mystat') => class => 
'dropdown-item'
+          %= link_to 'My Mirrors' => url_for('myserver') => class => 
'dropdown-item'
           % if (is_operator) {
           %= tag 'div' => class => 'dropdown-divider'
           %= tag 'h3' => class => 'dropdown-header' => 'Operator menu'

++++++ MirrorCache.obsinfo ++++++
--- /var/tmp/diff_new_pack.kBRusO/_old  2022-05-26 18:44:11.981187736 +0200
+++ /var/tmp/diff_new_pack.kBRusO/_new  2022-05-26 18:44:11.981187736 +0200
@@ -1,5 +1,5 @@
 name: MirrorCache
-version: 1.031
-mtime: 1651715583
-commit: 803caa1ca1f9052f26a89640756d347f515ad021
+version: 1.033
+mtime: 1652876909
+commit: f58f3923539b52c99a595c5654134826a15191c9
 

Reply via email to