[Unison-hackers] [unison-svn] r341 - in trunk/src: . system
vouillon@seas.upenn.edu
vouillon at seas.upenn.edu
Wed May 27 12:57:59 EDT 2009
Author: vouillon
Date: 2009-05-27 12:57:57 -0400 (Wed, 27 May 2009)
New Revision: 341
Modified:
trunk/src/RECENTNEWS
trunk/src/mkProjectInfo.ml
trunk/src/system/system_win.ml
trunk/src/system/system_win_stubs.c
Log:
* Windows Unicode API: when a file cannot be renamed due to a sharing
violation error or an access denied error, retry for up to 1 second,
in case the file is temporarily opened by an indexer or an anti-virus.
Modified: trunk/src/RECENTNEWS
===================================================================
--- trunk/src/RECENTNEWS 2009-05-27 12:15:17 UTC (rev 340)
+++ trunk/src/RECENTNEWS 2009-05-27 16:57:57 UTC (rev 341)
@@ -1,5 +1,12 @@
CHANGES FROM VERSION 2.34.0
+* Windows Unicode API: when a file cannot be renamed due to a sharing
+ violation error or an access denied error, retry for up to 1 second,
+ in case the file is temporarily opened by an indexer or an anti-virus.
+
+-------------------------------
+CHANGES FROM VERSION 2.34.0
+
* Text UI: during update detection, display status by updating a
single line rather than generating a new line of output every so
often. That should be less confusing.
Modified: trunk/src/mkProjectInfo.ml
===================================================================
--- trunk/src/mkProjectInfo.ml 2009-05-27 12:15:17 UTC (rev 340)
+++ trunk/src/mkProjectInfo.ml 2009-05-27 16:57:57 UTC (rev 341)
@@ -154,3 +154,4 @@
+
Modified: trunk/src/system/system_win.ml
===================================================================
--- trunk/src/system/system_win.ml 2009-05-27 12:15:17 UTC (rev 340)
+++ trunk/src/system/system_win.ml 2009-05-27 16:57:57 UTC (rev 341)
@@ -21,12 +21,6 @@
- Unix.select in lwt_unix (after some testing...)
- fix to daylight saving changes
-Try to rename several time if access denied the first time
-
-Remove 16Mib limit by using a temp file (or bigarray)
-http://caml.inria.fr/pub/ml-archives/caml-list/2004/06/2176c54608c3c39e2dbbd9365c2fc6bb.en.html
-http://caml.inria.fr/pub/ml-archives/caml-list/2007/01/04ef3c364e41f5f60f70192609d87035.en.html
-
- Use SetConsoleOutputCP/SetConsoleCP in text mode ???
http://www.codeproject.com/KB/cpp/unicode_console_output.aspx?display=Print
Modified: trunk/src/system/system_win_stubs.c
===================================================================
--- trunk/src/system/system_win_stubs.c 2009-05-27 12:15:17 UTC (rev 340)
+++ trunk/src/system/system_win_stubs.c 2009-05-27 16:57:57 UTC (rev 341)
@@ -101,10 +101,21 @@
CAMLprim value win_rename(value path1, value wpath1, value wpath2)
{
+ int err, t;
CAMLparam3(path1, wpath1, wpath2);
+
+ t = 10;
+ retry:
if (!MoveFileExW((LPWSTR)String_val(wpath1), (LPWSTR)String_val(wpath2),
MOVEFILE_REPLACE_EXISTING)) {
- win32_maperr (GetLastError ());
+ err = GetLastError ();
+ if ((err == ERROR_SHARING_VIOLATION || err == ERROR_ACCESS_DENIED) &&
+ t < 1000) {
+ Sleep (t);
+ t *= 2;
+ goto retry;
+ }
+ win32_maperr (err);
uerror("rename", path1);
}
CAMLreturn (Val_unit);
More information about the Unison-hackers
mailing list