Skip to content

Atomic writing should use FILE_RENAME_IGNORE_READONLY_ATTRIBUTE instead of manual unsetting #2078

Description

@jmschonfeld

Currently, when Foundation performs an atomic write, if the write fails and the destination file is marked as readonly, we attempt to remove the read-only flag and then try again. Instead, we should set the FILE_RENAME_IGNORE_READONLY_ATTRIBUTE flag when performing the rename. This way we can remove the unsafe and try again steps and make it a more correctly atomic, single operation. It looks like this flag is slightly newer, but @compnerd confirmed it's available in the minimum Windows version Swift supports.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindowsIssue regarding compiling/running on Windows

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions