File completed event never fires

Suggest, post, or discuss plugins for Deluge
Post Reply
quantcon
New User
New User
Posts: 2
Joined: Thu Jul 30, 2020 9:08 pm

File completed event never fires

Post by quantcon »

Hi, I am not receiving the TorrentFileCompletedEvent in my plugin. Here is a minimal code to reproduce the issue:

Code: Select all

from __future__ import unicode_literals

import logging

import deluge.configmanager
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component

log = logging.getLogger(__name__)

DEFAULT_PREFS = {
}


class Core(CorePluginBase):

    def enable(self):
        print('TestFileCompletedEvent enabled')
        self.config = deluge.configmanager.ConfigManager(
            'testfilecompletedevent.conf', DEFAULT_PREFS)


        # I've tried the following three ways:
       	
        # component.get('AlertManager').register_handler('file_completed_alert', self.on_file_completed)
        # component.get('AlertManager').register_handler('TorrentFileCompletedEvent', self.on_file_completed)
        component.get('EventManager').register_event_handler('TorrentFileCompletedEvent', self.on_file_completed)

    def on_file_completed(self, torrent_id, index):
        print('file completed, torrent_id {}, file index {}'.format(torrent_id, index))

I never get the alert. I've tried with other events like TorrentAddedEvent, and that seems to work just fine. Any ideas what I'm doing wrong?

EDIT: Just to clarify, this event is supposed to fire whenever any file in any torrent finishes downloading, right? At least that's what I got from the libtorrent docs.
quantcon
New User
New User
Posts: 2
Joined: Thu Jul 30, 2020 9:08 pm

Re: File completed event never fires

Post by quantcon »

I found the issue. The problem is that deluge doesn't add file_progress to the alert_mask (alertmanager.py line 52). Once I added it, I started receiving the alert.

I will file a bug. I think it should either be added by default or when an event handler for that alert category is registered.
Post Reply