Skip to content

Commit e3b19bc

Browse files
marcancas--
authored andcommitted
[Core] Work around libtorrent size limit
When loading a torrent_info by file path, libtorrent has a hardcoded size limit that some torrents exceed. This means that the torrent can be added normally to deluge, but on restart it fails to load the file from the state directory and the torrent is lost. Work around the hardcoded buffer size limit by reading in the file directly and passing the buffer. See: https://libtorrent-discuss.narkive.com/wYACQDb7/libtorrent-loading-a-big-torrent-fails Fixes: https://forum.deluge-torrent.org/viewtopic.php?t=56856 Closes: #483
1 parent 767c9c3 commit e3b19bc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

deluge/core/torrentmanager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pickle
1616
import time
1717
from base64 import b64encode
18+
from pathlib import Path
1819
from tempfile import gettempdir
1920
from typing import Dict, List, NamedTuple, Tuple
2021

@@ -338,8 +339,8 @@ def get_torrent_info_from_file(self, filepath):
338339
if log.isEnabledFor(logging.DEBUG):
339340
log.debug('Attempting to extract torrent_info from %s', filepath)
340341
try:
341-
torrent_info = lt.torrent_info(filepath)
342-
except RuntimeError as ex:
342+
torrent_info = lt.torrent_info(Path(filepath).read_bytes())
343+
except (RuntimeError, OSError) as ex:
343344
log.warning('Unable to open torrent file %s: %s', filepath, ex)
344345
else:
345346
return torrent_info

0 commit comments

Comments
 (0)