Author: brane
Date: Sat Feb 23 15:33:37 2019
New Revision: 1854216

URL: http://svn.apache.org/viewvc?rev=1854216&view=rev
Log:
Follow up to r1854072: Reduce the number of file-open operations on Windows.

* subversion/libsvn_subr/io.c (svn_io_dir_remove_nonrecursive):
   On Windows, only remove the read-only flag from the directory after
   the initial deletion failed.

Patch by: kotkov

Modified:
    subversion/trunk/subversion/libsvn_subr/io.c

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1854216&r1=1854215&r2=1854216&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Sat Feb 23 15:33:37 2019
@@ -4571,20 +4571,23 @@ svn_io_dir_remove_nonrecursive(const cha
 
   SVN_ERR(cstring_from_utf8(&dirname_apr, dirname, pool));
 
-  /* On Windows, a read-only directory cannot be removed. */
-#if defined(WIN32) || defined(__OS2__)
-  SVN_ERR(io_set_readonly_flag(dirname_apr, dirname,
-                               FALSE, FALSE, FALSE, pool));
-#endif
-
   status = apr_dir_remove(dirname_apr, pool);
 
 #ifdef WIN32
   {
     svn_boolean_t retry = TRUE;
 
+    if (APR_STATUS_IS_EACCES(status) || APR_STATUS_IS_EEXIST(status))
+      {
+        /* Make the destination directory writable because Windows
+           forbids deleting read-only items. */
+        SVN_ERR(io_set_readonly_flag(dirname_apr, dirname,
+                                     FALSE, FALSE, TRUE, pool));
+        status = apr_dir_remove(dirname_apr, pool);
+      }
+
     if (status == APR_FROM_OS_ERROR(ERROR_DIR_NOT_EMPTY))
-    {
+      {
         apr_status_t empty_status = dir_is_empty(dirname_apr, pool);
 
         if (APR_STATUS_IS_ENOTEMPTY(empty_status))


Reply via email to