Skip to content

TempFile#unlink - do not work if #close is not called right before, even if nothing has been done over the file. #678

@robertodecurnex

Description

@robertodecurnex
  temp_file = TempFile.new('name')
  temp_file.unlink

That won't blow nor delete the file.

Right now it just logs a warning asking to close the file before unlink.

That make sense if the file is actually opened but TempFile.new show create the file and the file reference without opening the stream.

Note that the problem is not present on other Ruby implementations.

Btw, the following will work great.

  temp_file = TempFile.new('name')
  temp_file.close
  temp_file.unlink

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions