Author: kotkov
Date: Tue Aug 20 09:09:54 2019
New Revision: 1865520

URL: http://svn.apache.org/viewvc?rev=1865520&view=rev
Log:
Win32: fix an incorrect error status being propagated to the caller in case
where we fail to stat the destination path while being in the middle of a
failed rename.

So, if we fail to stat the destination in the middle of such rename, propagate
the *original* error.  Because overriding the original error with the new one
loses information about the actual cause of failure and may even confuse some
of the callers, who for instance attempt to recover in case of an EACCES,
since they may not be receiving that error at all.

(This is the behavior we had for a long time, even before r1865518, but now
seems to be an appropriate moment to fix that)

* subversion/libsvn_subr/io.c
  (win32_file_rename): Use a separate `stat_err` for the case of the failed
   GetFileAttributes() call.  If we failed to stat the file, return the
   original `err` status to the caller.

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=1865520&r1=1865519&r2=1865520&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Tue Aug 20 09:09:54 2019
@@ -4500,8 +4500,9 @@ win32_file_rename(const WCHAR *from_path
           DWORD attrs = GetFileAttributesW(to_path_w);
           if (attrs == INVALID_FILE_ATTRIBUTES)
             {
-              err = apr_get_os_error();
-              if (!(APR_STATUS_IS_ENOENT(err) || 
SVN__APR_STATUS_IS_ENOTDIR(err)))
+              apr_status_t stat_err = apr_get_os_error();
+              if (!(APR_STATUS_IS_ENOENT(stat_err) || 
SVN__APR_STATUS_IS_ENOTDIR(stat_err)))
+                /* We failed to stat the file, propagate the original error */
                 return err;
             }
           else if (attrs & FILE_ATTRIBUTE_READONLY)
@@ -4514,6 +4515,7 @@ win32_file_rename(const WCHAR *from_path
                 {
                   err = apr_get_os_error();
                   if (!(APR_STATUS_IS_ENOENT(err) || 
SVN__APR_STATUS_IS_ENOTDIR(err)))
+                    /* We failed to set file attributes, propagate this new 
error */
                     return err;
                 }
             }


Reply via email to