From f3c40d610bfd4f3cccb1e1269effe5ba76c4cafe Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 9 Feb 2010 14:29:58 +0100 Subject: check error --- lib/githubexplorer/Repository.pm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/githubexplorer/Repository.pm b/lib/githubexplorer/Repository.pm index 7a402dd..664d727 100644 --- a/lib/githubexplorer/Repository.pm +++ b/lib/githubexplorer/Repository.pm @@ -15,6 +15,11 @@ sub fetch_repositories { my $repo_list = $github_profile->list(); + while ( ref $repo_list ne 'ARRAYREF' ) { + sleep(60); + $repo_list = $github_profile->list(); + } + foreach my $repos (@$repo_list) { next if $self->_repo_exists( $profile, $repos->{name} ); say "-> check " . $profile->login . "'s " . $repos->{name}; @@ -23,7 +28,8 @@ sub fetch_repositories { next; } my $repo_rs; - unless ( $repo_rs = $self->_repo_exists( $profile, $repos->{name} ) ) { + unless ( $repo_rs = $self->_repo_exists( $profile, $repos->{name} ) ) + { $repo_rs = $self->_create_repo( $profile, $repos ); say "== repository " . $repos->{name} . " created"; } @@ -35,15 +41,22 @@ sub fetch_repositories { token => $self->api_token, ); my $langs = $api_repos->languages; + while ( ref $langs ne 'HASHREF' ) { + sleep(60); + $langs = $api_repos->languages; + } + foreach my $lang ( keys %$langs ) { my $lang_rs = $self->_lang_exists($lang); - $self->schema->resultset('RepoLang')->create( - { - repository => $repo_rs->id, - language => $lang_rs->name, - size => $langs->{$lang}, - } - ); + try { + $self->schema->resultset('RepoLang')->create( + { + repository => $repo_rs->id, + language => $lang_rs->name, + size => $langs->{$lang}, + } + ); + }; } sleep(1); } -- cgit 1.4.1