From 5838b8e68ce51264a0047e48883f2e503b01edc8 Mon Sep 17 00:00:00 2001 From: chros Date: Thu, 25 Aug 2016 12:47:14 +0100 Subject: [PATCH] Fix fast resume script breaking single file torrents (See #7) --- doc/rtorrent_fast_resume.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/rtorrent_fast_resume.pl b/doc/rtorrent_fast_resume.pl index e01849f5..ea9daa8f 100755 --- a/doc/rtorrent_fast_resume.pl +++ b/doc/rtorrent_fast_resume.pl @@ -85,7 +85,7 @@ foreach my $f (0..$#files) { my $mtime = (stat "$d$files[$f]")[9]; # Compute number of chunks per file - my $fsize = $t->{info}{files}[$f]{length}; + my $fsize = (exists $t->{info}{files}) ? $t->{info}{files}[$f]{length} : 1; my $fchunks = ($pmod ? 1 : 0); if ($pmod >= $fsize) { ($fsize, $pmod ) = (0, $pmod-$fsize); } else { ($pmod, $fsize) = (0, $fsize-$pmod); } @@ -101,7 +101,10 @@ foreach my $f (0..$#files) { $t->{libtorrent_resume}{'uncertain_pieces.timestamp'} = time; # Some extra information to re-enforce the fact that this is a finished torrent -$d .= $t->{info}{name}; +if (exists $t->{info}{files}) { + $d .= $t->{info}{name}; +} + $t->{rtorrent} = { state => 1, # started state_changed => time,