Skip to content

Commit

Permalink
[backend] refactor checkbuildrepoid function
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Dec 7, 2012
1 parent bf9daed commit f2b69c0
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/backend/bs_sched
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,20 @@ my %watchremoteprojs; # tmp, only set in addwatchremote
my @retryevents;


sub checkbuildrepoid {
my ($projpacksin) = @_;
die("ERROR: source server did not report a repoid") unless $projpacksin->{'repoid'};
my $buildrepoid = readstr("$reporoot/_repoid", 1);
if (!$buildrepoid) {
# set the repoid on first run
$buildrepoid = $projpacksin->{'repoid'};
mkdir_p($reporoot) unless -d "$reporoot";
writestr("$reporoot/._repoid$$", "$reporoot/_repoid", $buildrepoid);
}
die("ERROR: My repository id($buildrepoid) has wrong length(".length($buildrepoid).")") unless length($buildrepoid) == 9;
die("ERROR: source server repository id($projpacksin->{'repoid'}) does not match my repository id($buildrepoid)") unless $buildrepoid eq $projpacksin->{'repoid'};
}

#
# get_projpacks: get/update project/package information
#
Expand Down Expand Up @@ -2201,22 +2215,7 @@ sub get_projpacks {
}

# Be sure that this is the right source server for my binary packages
die("ERROR: source server did not report a repoid") unless $projpacksin->{'repoid'};
my $buildrepoid;
eval {
$buildrepoid = readstr("$reporoot/_repoid");
};
unless ($buildrepoid) {
# set the repoid on first run
$buildrepoid = $projpacksin->{'repoid'};
mkdir_p("$reporoot") unless -d "$reporoot";
eval {
# it does not matter which bs_sched for which architecture succeeds to write this file
writestr("$reporoot/._repoid", "$reporoot/_repoid", $projpacksin->{'repoid'});
};
}
die("ERROR: My repository id($buildrepoid) has wrong length(".length($buildrepoid).")") unless length($buildrepoid) == 9;
die("ERROR: source server repository id($projpacksin->{'repoid'}) does not match my repository id($buildrepoid)") unless $buildrepoid eq $projpacksin->{'repoid'};
checkbuildrepoid($projpacksin);

for my $proj (@{$projpacksin->{'project'} || []}) {
if (@packids) {
Expand Down

0 comments on commit f2b69c0

Please sign in to comment.