Opened 11 months ago

#3603 new bug

Torrents not erroring as expected in libtorrent 2.0.9

Reported by: Cas Owned by:
Priority: major Milestone: 2.1.2
Component: Core Version: develop
Keywords: Cc:

Description

Our test suite started failing with latest libtorrent 2.0.9 in the tests related to setting a torrent to error state if files on disk are missing. This was implemented to resolve #1032 in Deluge.

This will require investigation as to expected libtorrent alerts and state and how Deluge should react to these scenarios.

The problem stems from a read_piece fix: https://github.com/arvidn/libtorrent/pull/7359

Related commits:

https://github.com/deluge-torrent/deluge/commit/0ab7ebd0177f281e https://github.com/deluge-torrent/deluge/commit/4ae43c5f2a697c6a5e546b416c081ae7b0839587

A quick script to identify the differences between libtorrent versions

import time
from pathlib import Path
import libtorrent as lt
from pprint import pprint

print('libtorrent: ', lt.__version__)
filename = 'deluge/tests/data/test_torrent.file.torrent'
filedump = Path(filename).read_bytes()
ti = lt.torrent_info(lt.bdecode(filedump))
atp = lt.add_torrent_params()
atp.save_path = '.'
atp.flags |= lt.torrent_flags.seed_mode
atp.ti = ti
sess = lt.session()
print('# Add torrent')
h = sess.add_torrent(atp)


def print_alerts(alerts):
    if not alerts:
        return
    alerts = [alert.what() for alert in alerts]
    print('[alerts] ', ', '.join(alerts))


state = ''
prev_state = ''
while str(state) != 'downloading':
    state = h.status().state
    if str(state) != str(prev_state):
        print('[state ] ', state)
        prev_state = state
    print_alerts(sess.pop_alerts())
    time.sleep(0.1)

print('# Read piece')
h.read_piece(0)
time.sleep(0.5)
print('[state ] ', h.status().state)
print_alerts(sess.pop_alerts())

Results:

libtorrent:  2.0.7.0
# Add torrent
[state ]  checking_resume_data
[alerts]  add_torrent
[state ]  checking_files
[alerts]  fastresume_rejected
[state ]  downloading
# Read piece
[state ]  downloading
[alerts]  file_error, torrent_error, file_error, torrent_error, read_piece
libtorrent:  2.0.9.0
# Add torrent
[state ]  checking_resume_data
[alerts]  add_torrent
[state ]  checking_files
[alerts]  fastresume_rejected
[state ]  downloading
# Read piece
[state ]  downloading
[alerts]  read_piece

Change History (0)

Note: See TracTickets for help on using tickets.