[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r16293 - trunk/subversion/libsvn_wc

From: Branko Čibej <brane_at_xbc.nu>
Date: 2005-09-27 13:51:07 CEST

dionisos@tigris.org wrote:

>Author: dionisos
>Date: Tue Sep 27 01:27:56 2005
>New Revision: 16293
>
>Modified:
> trunk/subversion/libsvn_wc/update_editor.c
>
>Log:
>Fix merge of added file where cwd is not on the same device as the target wc.
>
>* subversion/libsvn_wc/update_editor.c (install_file): Try copying the file
> when moving fails.
>
>
>
>Modified: trunk/subversion/libsvn_wc/update_editor.c
>Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/libsvn_wc/update_editor.c?rev=16293&p1=trunk/subversion/libsvn_wc/update_editor.c&p2=trunk/subversion/libsvn_wc/update_editor.c&r1=16292&r2=16293
>==============================================================================
>--- trunk/subversion/libsvn_wc/update_editor.c (original)
>+++ trunk/subversion/libsvn_wc/update_editor.c Tue Sep 27 01:27:56 2005
>@@ -1943,10 +1943,17 @@
> pointing to parent_dir/.svn/tmp/text-base/basename. */
> if (strcmp (final_location, new_text_path))
> {
>- SVN_ERR_W (svn_io_file_rename (new_text_path, final_location,
>- pool),
>- _("Move failed"));
>+ svn_error_t *err =
>+ svn_io_file_rename (new_text_path, final_location, pool);
>
>+ if (err)
>+ {
>+ svn_error_clear (err);
>+ SVN_ERR_W (svn_io_copy_file (new_text_path,
>+ final_location, TRUE, pool),
>+ _("Move failed"));
>+ SVN_ERR (svn_io_remove_file (new_text_path, pool));
>+ }
> new_text_path = final_location;
> }
> }
>
>
No way, man. Don't revert to copy+delete on any error, only on those
errors that actually represent a cross-device move.

A more fundamental problem with this change is that, presumably, the
original rename was supposed to be atomic. The way you do copy+delete
can leave the target file in an inconsistent state if the copy fails
halfway through. You should copy to a temorary file in the target
directory, then use a (guaranteed-local) rename there.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 27 14:42:02 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.