sapling/eden/scm/tests/test-mmap-unlink.t
Xavier Deguillard d6ca62a1d7 win32: when removing file, open it as O_TEMPORARY as a last effort
Summary:
When a file is mmap'ed, removing it will always fail, even with all the rename
magic. The only option that works is to ask the OS to remove the file when
there is no other file handles to it. In Python, we can use the O_TEMPORARY for
that.

Reviewed By: quark-zju

Differential Revision: D22224572

fbshipit-source-id: bee564a3006c8389f506633da5622aa7a27421ac
2020-06-24 20:34:47 -07:00

21 lines
398 B
Raku

#chg-compatible
$ cat <<EOF > mmap-unlink.py
> import mmap
> import os
> import shutil
>
> from edenscm.mercurial import util
>
> with util.posixfile("file", "w") as f:
> f.write("CONTENT")
>
> with util.posixfile("file", "r+b") as f:
> m = mmap.mmap(f.fileno(), 0)
> util.unlink("file")
> EOF
$ hg debugpython -- ./mmap-unlink.py
$ ls
mmap-unlink.py