File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -253,12 +253,19 @@ export class Deluge implements TorrentClient {
253
253
torrent : string | Buffer ,
254
254
config : Partial < AddTorrentOptions > = { } ,
255
255
) : Promise < AddTorrentResponse > {
256
- const upload = await this . upload ( torrent ) ;
257
- if ( ! upload . success || ! upload . files . length ) {
258
- throw new Error ( 'Failed to upload' ) ;
256
+ let path : string ;
257
+ if ( Buffer . isBuffer ( torrent ) || ! torrent . startsWith ( '/tmp/' ) ) {
258
+ const upload = await this . upload ( torrent ) ;
259
+ if ( ! upload . success || ! upload . files . length ) {
260
+ throw new Error ( 'Failed to upload' ) ;
261
+ }
262
+
263
+ path = upload . files [ 0 ] ;
264
+ } else {
265
+ /** Assume paths starting with /tmp/ are from {@link Deluge.addTorrent} */
266
+ path = torrent ;
259
267
}
260
268
261
- const path = upload . files [ 0 ] ;
262
269
const options : AddTorrentOptions = {
263
270
file_priorities : [ ] ,
264
271
add_paused : false ,
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ describe('Deluge', () => {
314
314
'https://releases.ubuntu.com/20.10/ubuntu-20.10-desktop-amd64.iso.torrent' ,
315
315
) ;
316
316
expect ( result ) . toContain ( '/tmp/' ) ;
317
- await client . addTorrent ( torrentFile , { add_paused : true } ) ;
317
+ await client . addTorrent ( result , { add_paused : true } ) ;
318
318
await pWaitFor (
319
319
async ( ) => {
320
320
const r = await client . listTorrents ( ) ;
You can’t perform that action at this time.
0 commit comments