'Save the file to the filename given in __init__.'

def _finish_file(self):

    if self._finished_file:
        log.downloads.debug('finish_file    called    twice,    ignored!')
        return
    self._finished_file = True
    log.downloads.debug('All    assets    downloaded,    ready    to    finish    off!')
    if isinstance(self.target, downloads.FileDownloadTarget):
        fobj = open(self.target.filename, 'wb')
    elif isinstance(self.target, downloads.FileObjDownloadTarget):
        fobj = self.target.fileobj
    elif isinstance(self.target, downloads.OpenFileDownloadTarget):
        try:
            fobj = downloads.temp_download_manager.get_tmpfile((self.tab.title() + '.mhtml'))
        except OSError as exc:
            msg = 'Download    error:    {}'.format(exc)
            message.error(msg)
            return
    else:
        raise ValueError('Invalid    DownloadTarget    given:    {!r}'.format(self.target))
    try:
        with fobj:
            self.writer.write_to(fobj)
    except OSError as error:
        message.error('Could    not    save    file:    {}'.format(error))
        return
    log.downloads.debug('File    successfully    written.')
    message.info('Page    saved    as    {}'.format(self.target))
    if isinstance(self.target, downloads.OpenFileDownloadTarget):
        utils.open_file(fobj.name, self.target.cmdline)
