This file is indexed.

/usr/lib/obs/server/BSSched/RepoCache.pm is in obs-server 2.7.1-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
# Copyright (c) 2015 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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 (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
package BSSched::RepoCache;

use strict;
use warnings;

sub new {
  my ($class, $arch, $reporoot) = @_;
  my $self = {
    'arch' => $arch,
    'reporoot' => $reporoot,
  };
  return bless $self, $class;
}

sub setcache {
  my ($self, $prp, $arch, %conf) = @_;

  my $repodata = $self->{"$prp/$arch"};
  $self->{"$prp/$arch"} = $repodata = {} unless $repodata;
  delete $repodata->{$_} for qw{solv solvfile error lastscan random};
  my $isremote = delete $conf{'isremote'};
  $repodata->{$_} = $conf{$_} for keys %conf;
  # we don't cache local alien repos
  if ($isremote || $arch eq $self->{'arch'}) {
    $repodata->{'lastscan'} = time();
    $repodata->{'random'} = rand();
  }
}

sub addrepo {
  my ($self, $pool, $prp, $arch) = @_;

  my $repodata = $self->{"$prp/$arch"};
  if ($repodata && $repodata->{'lastscan'} && $repodata->{'lastscan'} + 24 * 3600 + ($repodata->{'random'} || 0) * 1800 > time()) {
    if ($repodata->{'error'}) {
      print "    repo $prp/$arch: $repodata->{'error'}\n";
      return undef;
    }
    if (exists $repodata->{'solv'}) {
      my $r;
      eval {$r = $pool->repofromstr($prp, $repodata->{'solv'});};
      return $r if $r;
      delete $repodata->{'solv'};	# bad data
    }
    my $solvfile = $repodata->{'solvfile'} || "$self->{'reporoot'}/$prp/$arch/:full.solv";
    if (-s $solvfile) {
      my $r;
      if ($repodata->{'solvfile'}) {
	my $now = time();
        my @s = stat _;
        utime($now, $s[9], $solvfile) if $s[8] + 60 < $now; # update atime (remote cache case)
      }
      eval {$r = $pool->repofromfile($prp, $solvfile);};
      return $r if $r;
    }
  }

  # nope, can't use it
  if ($repodata) {
    # free some mem
    delete $repodata->{'solv'};
    delete $repodata->{'solvfile'};
    delete $repodata->{'lastscan'};
    delete $repodata->{'random'};
    delete $repodata->{'error'};
  }
  return 0;	# not in cache
}

sub drop {
  my ($self, $prp, $arch) = @_;
  if (defined($prp)) {
    delete $self->{"$prp/$arch"};
  } else {
    %$self = ( 'arch' => $self->{'arch'}, 'reporoot' => $self->{'reporoot'} );
  }
}

sub dropmeta {
  my ($self, $prp, $arch) = @_;
  delete $self->{"$prp/$arch"}->{'meta'} if $self->{"$prp/$arch"};
}

sub dropsolv {
  my ($self, $prp, $arch) = @_;
  delete $self->{"$prp/$arch"}->{'solv'} if $self->{"$prp/$arch"};
}

1;