Skip to content

Commit

Permalink
[backend] bs_dbtool: do not die right away if an entry could not be f…
Browse files Browse the repository at this point in the history
…etched

Instead, collect the bad entry and print them at the end of the
conversion.
  • Loading branch information
mlschroe committed Apr 2, 2020
1 parent 1cb03a4 commit 8daae53
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/backend/bs_dbtool
Expand Up @@ -66,6 +66,7 @@ if ($table eq 'linkinfo') {
}
$db->{'allkeyspath'} = 'name';
$db->{'allkeyspath'} = 'project' if $table eq 'repoinfo';
delete $db->{'allkeyspath'} if ($table eq 'repoinfo' || $table eq 'pattern') && !$BSConfig::published_db_sqlite;
} else {
die("unknown database table $table\n");
}
Expand Down Expand Up @@ -213,29 +214,50 @@ if ($cmd eq 'convert') {
}
$ndb->asyncmode();

my @bad;
for my $prp (@todo) {
my $prp_ext = $prp;
$prp_ext =~ s/:/:\//g;

if ($table eq 'linkinfo') {
my ($projid, $packid) = split('/', $prp, 2);
my $linkinfo = $db->fetch($prp) || die;
my $linkinfo = $db->fetch($prp);
if (!$linkinfo) {
push @bad, $prp;
warn("could not fetch $bad[-1]\n");
next;
}
$ndb->store_linkinfo($projid, $packid, $linkinfo);
} elsif ($table eq 'pattern') {
my $patterninfo = {};
for my $path (sort keys %{$todo_pattern{$prp}}) {
$patterninfo->{$path} = $db->fetch("$prp_ext/$path") || die;
my $pi = $db->fetch("$prp_ext/$path");
if (!$pi) {
push @bad, "$prp_ext/$path";
warn("could not fetch $bad[-1]\n");
next;
}
$patterninfo->{$path} = $pi;
}
$ndb->updatedb_patterninfo($prp, $patterninfo);
} elsif ($table eq 'binary') {
my $repoinfo = $db->fetch($prp) || die;
my $repoinfo = $db->fetch($prp);
if (!$repoinfo) {
push @bad, $prp;
warn("could not fetch $bad[-1]\n");
next;
}
$ndb->updatedb_repoinfo($prp, $repoinfo);
}

$done++;
print "$done/$todo\n" if $done % 10 == 0;
}
print "$todo/$todo\n";
if (@bad) {
print "WARNING: could not fetch the following entries:\n";
print " - $_\n" for @bad;
}
exit(0);
}

Expand Down

0 comments on commit 8daae53

Please sign in to comment.