Add resume support to downloading

This commit is contained in:
Tony Blyler 2016-05-14 11:32:24 -04:00
parent 93cf0597ed
commit a08a102d15
No known key found for this signature in database
GPG key ID: 25C9D3A655D1A65C
2 changed files with 5 additions and 1 deletions

View file

@ -34,6 +34,9 @@ rtorrent_update_interval: 60000000000
# The number of concurrent completed torrent downloads to have at one time
download_jobs: 2
# Whether or not to attempt to resume a previously interrupted download
resume_downloads: true
rtorrent:
# The address to the rtorrent XMLRPC endpoint
addr: mycoolrtorrentserver.com/XMLRPC

View file

@ -40,6 +40,7 @@ type Config struct {
FinishedTorrentFilePath map[string]string `json:"watch_to_finish_path" yaml:"watch_to_finish_path,flow"`
TorrentListUpdateInterval time.Duration `json:"rtorrent_update_interval" yaml:"rtorrent_update_interval"`
ConcurrentDownloads uint `json:"download_jobs" yaml:"download_jobs"`
ResumeDownloads bool `json:"resume_downloads" yaml:"resume_downloads"`
}
// Queue watches the given folders for new .torrent files,
@ -289,7 +290,7 @@ func (q *Queue) downloadTorrents(torrents []rtorrent.Torrent) {
go func(torrentFilePath string, downloadPath string, torrent rtorrent.Torrent) {
q.logger.Printf("Downloading '%s' (%s) to '%s' (%s) %s", torrent.Name, torrentFilePath, downloadPath, destDownloadPath, prettyBytes(float64(torrent.Size)))
err := q.sftpClient.Mirror(torrent.Path, downloadPath)
err := q.sftpClient.Mirror(torrent.Path, downloadPath, q.config.ResumeDownloads)
if err != nil {
q.logger.Printf("Failed to download '%s' to '%s' error '%s'", torrent.Path, downloadPath, err)
done <- ""