'Callback for the alert that contains the resume data of a specific download.
This resume data will be written to a file on disk.'

def on_save_resume_data_alert(self, alert):

    resume_data = alert.resume_data
    self.pstate_for_restart = self.get_persistent_download_config()
    self.pstate_for_restart.set('state', 'engineresumedata', resume_data)
    self._logger.debug('%s    get    resume    data    %s', hexlify(resume_data['info-hash']), resume_data)
    basename = (hexlify(resume_data['info-hash']) + '.state')
    filename = os.path.join(self.session.get_downloads_pstate_dir(), basename)
    self._logger.debug('tlm:    network    checkpointing:    to    file    %s', filename)
    self.pstate_for_restart.write_file(filename)
    for deferred_r in self.deferreds_resume:
        deferred_r.callback(resume_data)
    self.deferreds_resume = []
