Page 1 of 1

File completed event never fires

Posted: Thu Jul 30, 2020 9:18 pm
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.

Re: File completed event never fires

Posted: Sun Aug 02, 2020 12:30 pm
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.