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

Re: svn 0.34.0, 0.35.1 windows access is denied on delete directory

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2004-01-15 21:55:15 CET

Philip Martin <philip@codematters.co.uk> writes:

> solo turn <soloturn99@yahoo.com> writes:
>
>> U com\utils\ResourceBundle.java
>> svn: Problem on first log entry in a working copy
>> svn: In directory 'com/xml'
>> svn: Error processing command 'delete-entry' in 'com/xml'
>> svn: Access is denied.
>> svn: svn_io_remove_dir: removing 'com/xml/datainterchange/.svn'
>>
>> could it be there is still a problem remaining?
>
> I don't think anything has changed since the last time this was
> reported. It appears that apr_dir_remove in svn_io_remove_dir needs a
> loop similar to the one around apr_file_remove in svn_io_remove_file.
> It doesn't look hard, bonus points are available for factoring the
> loop into some common code.

This may not compile as I don't have a Windows machine. Perhaps
someone who does would: a) compile it, b) reproduce the original
problem, and c) confirm whether this fixes it.

Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 8319)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -972,6 +972,50 @@
 
 /* Deletion. */
 
+/* Call DELETE_FN(PATH,POOL) to delete PATH and jump through platform
+ * specific hoops to make it work. PATH should be in native encoding and
+ * DELETE_FN should be either apr_file_remove or apr_dir_remove. The
+ * caller is resposible for making the file/directory decision.
+ */
+static apr_status_t
+delete_path (apr_status_t (*delete_fn)(const char *, apr_pool_t *),
+ const char *path,
+ apr_pool_t *pool)
+{
+ apr_status_t apr_err = delete_fn (path, pool);
+
+#ifdef WIN32
+ /*
+ Windows is 'aided' by a number of types of applications that
+ follow other applications around and open up files they have
+ changed for various reasons (the most intrusive are virus
+ scanners). So, if one of these other apps has glommed onto
+ one of our files we may get an 'access denied' error.
+
+ This retry loop does not completely solve the problem (who
+ knows how long the other app is going to hold onto the file), but
+ goes a long way towards minimizing it. It is not an infinite
+ loop because there might really be an error.
+ */
+ {
+ int retries = 0;
+ int sleep_count = 1000;
+
+ for ( retries = 0;
+ APR_TO_OS_ERROR (apr_err) == ERROR_ACCESS_DENIED && retries < 100;
+ ++retries )
+ {
+ apr_sleep (sleep_count);
+ if (sleep_count < 128000)
+ sleep_count *= 2;
+ apr_err = delete_fn (path, pool);
+ }
+ }
+#endif /* WIN32 */
+
+ return apr_err;
+}
+
 svn_error_t *
 svn_io_remove_file (const char *path, apr_pool_t *pool)
 {
@@ -997,37 +1041,7 @@
 
   SVN_ERR (svn_path_cstring_from_utf8 (&path_apr, path, pool));
 
- apr_err = apr_file_remove (path_apr, pool);
-
-#ifdef WIN32
- /*
- Windows is 'aided' by a number of types of applications that
- follow other applications around and open up files they have
- changed for various reasons (the most intrusive are virus
- scanners). So, if one of these other apps has glommed onto
- our file we may get an 'access denied' error.
-
- This retry loop does not completely solve the problem (who
- knows how long the other app is going to hold onto it for), but
- goes a long way towards minimizing it. It is not an infinite
- loop because there might really be an error.
- */
- {
- int retries = 0;
- int sleep_count = 1000;
-
- for ( retries = 0;
- APR_TO_OS_ERROR (apr_err) == ERROR_ACCESS_DENIED && retries < 100;
- ++retries )
- {
- apr_sleep (sleep_count);
- if (sleep_count < 128000)
- sleep_count *= 2;
- apr_err = apr_file_remove (path_apr, pool);
- }
- }
-#endif /* WIN32 */
-
+ apr_err = delete_path (apr_file_remove, path_apr, pool);
   if (apr_err)
     return svn_error_wrap_apr (apr_err, "Can't remove file '%s'", path);
 
@@ -1108,7 +1122,7 @@
   if (status)
     return svn_error_wrap_apr (status, "Error closing directory '%s'", path);
 
- status = apr_dir_remove (path_apr, subpool);
+ status = delete_path (apr_dir_remove, path_apr, subpool);
   if (status)
     return svn_error_wrap_apr (status, "Can't remove '%s'", path);
 

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jan 15 21:56:33 2004

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