Skip to content

'TftpFileNotFoundError' is not processed correctly in TftpContexts.py->TftpContextClientDownload->start() #134

@LeoWeiLeoWei

Description

@LeoWeiLeoWei
except TftpFileNotFoundError as err:
       # If we received file not found, then we should not save the open
       # output file or we'll be left with a size zero file. Delete it,
       # if it exists.
       log.error("Received File not found error")
       if self.fileobj is not None and not self.filelike_fileobj:
           if os.path.exists(self.fileobj.name):
                log.debug("unlinking output file of %s", self.fileobj.name)
                os.unlink(self.fileobj.name)

       raise

When downloading a file that not exists on TFTP-Server. The local file object has been opened in init(), but not closed yet here. So, when calling os.unlink(), it will raise another exception 'PermissionError'.
Please confirm and fix it. Thanks very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingNot looking at it yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions