Skip to content

Trying to read an invalid .xml file makes it so that the file cannot be deleted #376

@billdenney

Description

@billdenney

When trying to read an invalid .xml file, I cannot delete the. I think that this is because the connection remains open. If important, this happens on Windows (I've not tested other operating systems).

filename <- tempfile(fileext = ".xml")
bad_xml_file <- writeLines("<a>", con = filename)
file.remove(filename)
#> [1] TRUE

filename <- tempfile(fileext = ".xml")
bad_xml_file <- writeLines("<a>", con = filename)
xml2::read_xml(filename)
#> Error in read_xml.character(filename): EndTag: '</' not found [74]
file.remove(filename)
#> Warning in file.remove(filename): cannot remove file 'C:
#> \Users\wdenn\AppData\Local\Temp\RtmpQR65s3\file5e74463b35d8.xml', reason
#> 'Permission denied'
#> [1] FALSE

Created on 2022-10-29 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions