Skip to content

handle_user_provided_file leaves an empty temp file #414

Open

Description

@ahmershahdev

When dest is not given, handle_user_provided_file() creates a NamedTemporaryFile(delete=False) before it knows whether it needs one. Two paths never use it, so an empty file is left behind:

  • nocopy=True with a local path returns source, and the temp file stays in in_dir (or the system temp directory).
  • A local path that does not exist raises OSError, and the temp file stays too.

nautilus (collection file) and kolibri2zim (custom about page and CSS, with in_dir=self.build_dir) call it with nocopy=True, so each of those runs given a local path leaves an empty tmp* file.

Proposed fix: create the temporary dest only in the download and copy branches, after the nocopy return and the existence check, and add tests that in_dir stays empty in both cases.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions