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.
Fixes #1181.
os.rename()
has different behaviors on Windows vs Linux, usingos.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 whatos.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