[MERGE] [BUG 363837] Catch _win32_delete_readonly failure to remove file or directory and try to recover
mbp at sourcefrog.net
Tue May 5 23:18:23 BST 2009
2009/5/6 Maritza Mendez <martitzam at gmail.com>:
> The more I think about this, the more I think that a cure may be worse than
> the problem. So I am leaning toward (quoting myself yesterday):
> Maritza Mendez wrote:
>> So maybe the correct approach for diff (and merge) is to tolerate the
>> leftover temp files and print a friendly message saying that they were left
>> behind but allow execution to continue as if nothing went wrong. Since bzr
>> does not need (and will not re-use) these files, there is no real harm. The
>> user has been advised and then it is up to him if to do anything. Since bzr
>> uses a well-known system temp folder, routine maintenance should clean it
>> out anyway.
> In other words, bzr would catch the exception, print a polite message about
> the external misbehavior, and just keep going. The only real difference
> between that and what happens now is that bzr would no longer pass an
> unhandled exception which causes users concern. I have not thought about
> how this change might affect external wrappers like tbzr...
Yes, just printing a message that you failed to delete them and then
leaving them there makes sense to me.
In a sense, this is actually more correct behaviour: Windows prohibits
deletion of the files because they're still in use; therefore we
should leave them on disk. (In practice, you'd think that for most
moderately small files the program would read them into memory and
then no longer care whether they exist on disk, but maybe not.)
I think recent Windows releases do have some facility for
automatically cleaning their temp directory.
Although the above is sufficient, there is another option: I think
Windows has a 'delete on close' flag when creating files. I don't
know if this propagates properly when multiple processes open the
file, and even if it does there may be a race when the external
program's starting up.
More information about the bazaar