2011/2/26 Branko Čibej <brane_at_e-reka.si>:
> On 26.02.2011 10:50, Ivan Zhakov wrote:
>> 2011/2/26 Branko Čibej <brane_at_e-reka.si>:
>>> On 26.02.2011 07:32, Ivan Zhakov wrote:
>>>> Problem of re-installing file over marked for deletion file can be
>>>> solved using the following trick:
>>>> 1. Rename file to temporary name.
>>>> 2. Delete it
>>> (If the proper share bits are set.)
>>>
>> Sure.
>
> It turns out that the FILE_SHARE_DELETE bit is the one that allows renames.
>
Yes, you're right.
>>> Yes, that'd work, but if there's a way to unmark the deletion bit,
>>> that's even better, since then you'd not even have to create another
>>> file (with identical contents).
>>>
>> I'm not aware how to unmark deletion bit on Windows.
>
> You're right, there's no way to do it from user space. I suppose then
> that the easiest thing to do on Windows would be this: when a pristine
> needs to be deleted, instead of just deleting it, rename it to some
> unique random name within the same directory, and delete that. This way,
> you don't need extra logic for the "reinstate" step, nor do you have to
> ever check if there are open handles to the file. Rename (clearing the
> way for reinstate) and delete (the file goes away when all handles are
> closed) and apr_file_open already sets all the required share bits.
>
That's exactly what I was suggesting.
Btw I think it makes sense rename file to tmp directory in working
copy instead of pristines directory, since it could be crash/failure
between rename and delete. In this case pristines directory will
polluted with orphaned pristines.
> BTW Julian, have you considered making the pristine files read-only
> (once they're written of course)? If yes, then be aware that in order to
> delete and/or rename a file on Windows, you have to first clear the
> read-only bit. I think we have utility functions for that in
> libsvn_subr, but it's worth a check.
>
Makes sense for me.
--
Ivan Zhakov
VisualSVN Team
Received on 2011-02-26 20:41:22 CET