Skip to content

Commit

Permalink
stop on empty next_marc
Browse files Browse the repository at this point in the history
  • Loading branch information
dpavlin committed Apr 26, 2012
1 parent eb4809f commit bf6018a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions DPLA.pm
Expand Up @@ -151,11 +151,19 @@ sub next_marc {

diag "# marc ", $marc->as_formatted;

my $id = $item->{'dpla.id'} || warn "no dpla.id in ",dump($item);
$self->save_marc( "$id.marc", $marc->as_usmarc );
warn dump( $marc->as_usmarc );

$self->mech->back; # return to search results for next page

my $id = $item->{'dpla.id'};

if ( ! $id ) {
warn "no dpla.id in ",dump($item);
return;
}

$self->save_marc( "$id.marc", $marc->as_usmarc );

return $id;

}
Expand Down
4 changes: 3 additions & 1 deletion server.pl
Expand Up @@ -149,7 +149,9 @@ sub FetchHandle {
my $from = $rs->{from} || die "no from?";
# fetch records up to offset
while( $#{ $rs->{results} } < $offset ) {
push @{ $rs->{results} }, $from->next_marc;
my $marc = $from->next_marc;
last if ! $marc; # abort results
push @{ $rs->{results} }, $marc;
warn "# rs result ", $#{ $rs->{results} },"\n";
}

Expand Down

0 comments on commit bf6018a

Please sign in to comment.