Skip to content

Commit

Permalink
feat(): works with 0 torrent in rtorrent
Browse files Browse the repository at this point in the history
  • Loading branch information
al3xLvs committed Jun 3, 2020
1 parent d109871 commit ce41ae7
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"ext-json": "*",
"ext-iconv": "*",
"ext-xmlrpc": "*",
"symfony/console": "3.4.* || 5.0.*",
"symfony/finder": "3.4.* || 5.0.*",
"symfony/stopwatch": "3.4.* || 5.0.*"
"symfony/console": "3.4.* || 5.1.*",
"symfony/finder": "3.4.* || 5.1.*",
"symfony/stopwatch": "3.4.* || 5.1.*"
},
"config": {
},
Expand Down
5 changes: 4 additions & 1 deletion src/Cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ protected function getFileListFromRtorrent()
$torrents = $this->rtorrent->call('d.multicall2', ['', 'default', 'd.hash=', 'd.name=', 'd.directory=']);
$this->numTorrents = count($torrents);
$this->missingFileData = [];
$this->rtorrentFileData = [];

if ($this->numTorrents === 0) {
throw new \Exception('No torrent found in rtorrent.');
$this->directories[] = $this->rtorrent->call('directory.default');

return $this;
}

$progressBar = new ProgressBar($this->output, $this->numTorrents);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$table->render();
}

$date = (new \DateTime())->format('D, j M Y H:i:s');
$date = (new \DateTime())->format('d/m/Y H:i:s');
$event = $time->stop();
$time = Helpers::humanTime($event->getDuration());
$output->writeln(['', '> time: '.$time.', date: '.$date]);
Expand Down
4 changes: 2 additions & 2 deletions src/Command/MoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$date = (new \DateTime())->format('D, j M Y H:i:s');
$date = (new \DateTime())->format('d/m/Y H:i:s');
$torrents = $cleaner->getnumTorrents();
$space = Helpers::convertFileSize($cleaner->getFreeDiskSpace(), 2);
$event = $time->stop();
$time = Helpers::humanTime($event->getDuration());
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free space: '.$space.', date: '.$date]);
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free: '.$space.', date: '.$date]);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/RemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$date = (new \DateTime())->format('D, j M Y H:i:s');
$date = (new \DateTime())->format('d/m/Y H:i:s');
$torrents = $cleaner->getnumTorrents();
$space = Helpers::convertFileSize($cleaner->getFreeDiskSpace(), 2);
$event = $time->stop();
$time = Helpers::humanTime($event->getDuration());
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free space: '.$space.', date: '.$date]);
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free: '.$space.', date: '.$date]);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$console->writeln('> <fg=green>No missing files.</>');
}

$date = (new \DateTime())->format('D, j M Y H:i:s');
$date = (new \DateTime())->format('d/m/Y H:i:s');
$torrents = $cleaner->getnumTorrents();
$space = Helpers::convertFileSize($cleaner->getFreeDiskSpace(), 2);
$event = $time->stop();
$time = Helpers::humanTime($event->getDuration());
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free space: '.$space.', date: '.$date]);
$console->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free: '.$space.', date: '.$date]);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/TorrentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$date = (new \DateTime())->format('D, j M Y H:i:s');
$date = (new \DateTime())->format('d/m/Y H:i:s');
$torrents = $cleaner->getnumTorrents();
$space = Helpers::convertFileSize($cleaner->getFreeDiskSpace(), 2);
$event = $time->stop();
$time = Helpers::humanTime($event->getDuration());
$output->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free space: '.$space.', date: '.$date]);
$output->writeln(['', '> time: '.$time.', torrents: '.$torrents.', free: '.$space.', date: '.$date]);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Application extends BaseApplication
{
private $version = '0.9.7';
private $version = '0.9.8';
private $name = 'rtorrent-cleaner';

public function __construct()
Expand Down

0 comments on commit ce41ae7

Please # to comment.