Ticket #3367: deluge-2.0.3+add_torrents_instream.patch

File deluge-2.0.3+add_torrents_instream.patch, 1.0 KB (added by lalbornoz, 4 years ago)
  • ui/web/json_api.py

    old new  
    724724        Add torrents by file 
    725725 
    726726        :param torrents: A list of dictionaries containing the torrent \ 
    727             path and torrent options to add with. 
     727            path, torrent data and torrent options to add with. Torrent data \ 
     728            is optional and must be encoded with base64. 
    728729        :type torrents: list 
    729730 
    730731        :: 
     
    748749                deferreds.append(d) 
    749750            else: 
    750751                filename = os.path.basename(torrent['path']) 
    751                 with open(torrent['path'], 'rb') as _file: 
    752                     fdump = b64encode(_file.read()) 
     752                fdump = torrent.pop("data", None) 
     753                if fdump == None: 
     754                    with open(torrent['path'], 'rb') as _file: 
     755                        fdump = b64encode(_file.read()) 
    753756                log.info( 
    754757                    'Adding torrent from file `%s` with options `%r`', 
    755758                    filename,