emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

Fix FileExistsError on subsequent bazel builds on Windows #1326

Closed NovaSagittarii closed 6 months ago

NovaSagittarii commented 6 months ago

Fixes #1181. os.rename() has different behaviors on Windows vs Linux, using os.replace() instead fixes the issue when a new build is created when previous files exist from an older build.

I'm not sure if this is the best way to do this though since there's the method move_with_overwrite() in emsdk.py which does what os.replace() is supposed to do. Regarding atomicity, according to python documentation, os.replace()'s renaming is atomic as a POSIX requirement, but Windows isn't fully POSIX compliant.

https://github.com/emscripten-core/emsdk/blob/8822664a145391eee7cb57f9db7ba3705e19f2fe/emsdk.py#L547-L553