Browse Source

retry on 409 and consistent season directories

themage
theMage 5 years ago
parent
commit
4967b0dbd0
2 changed files with 6 additions and 2 deletions
  1. 5 1
      lib/CinePantufas/Client/Transmission.pm
  2. 1 1
      lib/CinePantufas/Core.pm

+ 5 - 1
lib/CinePantufas/Client/Transmission.pm

@ -31,6 +31,7 @@ sub import {
31 31
sub add_torrent {
32 32
  my $class = shift;
33 33
  my $link  = shift;
34
  my $retry = shift // 3;
34 35
35 36
  my $config = CinePantufas::Setup->config('transmission');
36 37
  my $url = $config->{api_url};
@ -70,9 +71,12 @@ sub add_torrent {
70 71
                    ||'',
71 72
      };
72 73
    }
74
  } elsif ( $resp->{status} == 409 and $retry--) {
75
    $session = undef;
76
    return $class->add_torrent( $link, $retry );
73 77
  } else {
74 78
    my $more = $ENV{DEBUG} ? $resp->{content} : '';
75
    die "error on transmission: $resp->{status} $resp->{reason}\n$more\n";
79
    warn "error on transmission: $resp->{status} $resp->{reason}\n$more\n";
76 80
  }
77 81
78 82
  return 0;

+ 1 - 1
lib/CinePantufas/Core.pm

@ -458,7 +458,7 @@ sub __copy_files {
458 458
  $dest .= $info->{show}.'/';
459 459
  mkdir $dest unless -d $dest;
460 460
461
  $dest .= 'Season'.$info->{season}.'/';
461
  $dest .= sprintf 'Season%02d/',$info->{season};
462 462
  mkdir $dest unless -d $dest;
463 463
464 464
  die "error creating directory $dest\n" unless -d $dest;