[Python-ideas] shutil.symlink to allow non-race replacement of existing link targets
Antoine Pitrou
solipsis at pitrou.net
Thu May 16 11:22:35 EDT 2019
On Thu, 16 May 2019 18:05:39 +0300
Serhiy Storchaka <storchaka at gmail.com>
wrote:
> 16.05.19 17:05, Antoine Pitrou пише:
> > On Thu, 16 May 2019 16:04:36 +0300
> > Serhiy Storchaka <storchaka at gmail.com>
> > wrote:
> >> 16.05.19 14:33, Antoine Pitrou пише:
> >>> On Thu, 16 May 2019 13:05:48 +0300
> >>> Serhiy Storchaka <storchaka at gmail.com>
> >>> wrote:
> >>>> 16.05.19 11:28, Barry Scott пише:
> >>>>> To replace one symlink with another atomically is possible by using rename() or renameat()
> >>>>> something like:
> >>>>>
> >>>>> os.symlink( src, tmp_symlink )
> >>>>> os.rename( tmp_symlink, dst )
> >>>>
> >>>> Somebody can replace tmp_symlink between os.symlink() and os.rename().
> >>>
> >>> Not if tmp_symlink is created in a directory with strict permissions, I
> >>> guess.
> >>
> >> But in such case we do not need complex games with a temporary symlink.
> >> Just use os.symlink() and os.unlink() if needed.
> >
> > I was talking about the *tmp_symlink*, not *dst*.
>
> They both should be on the same file system. The simplest way to achieve
> this is to create tmp_symlink in the same directory as dst.
So what?
More information about the Python-ideas
mailing list