Skip to content

writeFileSync may error with cross-device link not permitted on WindowsΒ #71

@davidmurdoch

Description

@davidmurdoch

Windows apps installed via .appx may be installed to any drive the user chooses. From what I understand, when an appx application is executed, the file system is virtualized; Windows lies to the application about where it is running from, and when the application accesses a file, Windows proxies the calls across from the virtualized location to the actual location.

Example: if Windows is installed on C:, I can install an AppX application on D:. When the application is launched, Windows will the application CWD will be C:\Users\David\AppData\Roaming\{AppName} instead of somewhere on the D: drive.

(note: I could be wrong about what Windows is really doing here!)

All that to say... the following call to fs.renameSync may fail with a cross-device link not permitted error. I wish Windows would handle this internally, as this really seems more like a Windows bug than bug in write-file-atomic to me.

fs.renameSync(tmpfile, filename)

A potential solution may be to first try the rename, then try a copy + delete operation if that rename fails.

related issue: trufflesuite/ganache-ui#1943

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