You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2019/01/21 14:19:33 UTC

svn commit: r1851744 - in /subversion/trunk/subversion: include/svn_delta.h libsvn_client/wc_editor.c

Author: julianfoad
Date: Mon Jan 21 14:19:32 2019
New Revision: 1851744

URL: http://svn.apache.org/viewvc?rev=1851744&view=rev
Log:
A follow-up to r1851739: close the streams we opened.

(Found because the rename attempt failed on Windows.)

* subversion/include/svn_delta.h
  (svn_txdelta_apply): Document that it closes its target stream but not its
    source stream.

* subversion/libsvn_client/wc_editor.c
  (file_baton_t
   file_textdelta,
   file_close): Close the source stream before we try to overwrite the file
    it was reading from.

Modified:
    subversion/trunk/subversion/include/svn_delta.h
    subversion/trunk/subversion/libsvn_client/wc_editor.c

Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1851744&r1=1851743&r2=1851744&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Mon Jan 21 14:19:32 2019
@@ -495,6 +495,10 @@ svn_txdelta_send_contents(const unsigned
  * since there's nothing else in the delta application's context to
  * supply a path for error messages.)
  *
+ * The @a source stream will NOT be closed. The @a target stream will be
+ * closed when the window handler is given a null window to signal the
+ * end of the delta.
+ *
  * @note To avoid lifetime issues, @a error_info is copied into
  * @a pool or a subpool thereof.
  */

Modified: subversion/trunk/subversion/libsvn_client/wc_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/wc_editor.c?rev=1851744&r1=1851743&r2=1851744&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/wc_editor.c (original)
+++ subversion/trunk/subversion/libsvn_client/wc_editor.c Mon Jan 21 14:19:32 2019
@@ -351,6 +351,7 @@ struct file_baton_t
   const char *writing_file;
   unsigned char digest[APR_MD5_DIGESTSIZE];
 
+  svn_stream_t *wc_file_read_stream, *tmp_file_write_stream;
   const char *tmp_path;
 };
 
@@ -473,27 +474,25 @@ file_textdelta(void *file_baton,
   struct file_baton_t *fb = file_baton;
   const char *target_dir = svn_dirent_dirname(fb->local_abspath, fb->pool);
   svn_error_t *err;
-  svn_stream_t *source;
-  svn_stream_t *target;
 
   SVN_ERR_ASSERT(! fb->writing_file);
 
-  err = svn_stream_open_readonly(&source, fb->local_abspath,
+  err = svn_stream_open_readonly(&fb->wc_file_read_stream, fb->local_abspath,
                                  fb->pool, fb->pool);
   if (err && APR_STATUS_IS_ENOENT(err->apr_err))
     {
       svn_error_clear(err);
-      source = svn_stream_empty(fb->pool);
+      fb->wc_file_read_stream = svn_stream_empty(fb->pool);
     }
   else
     SVN_ERR(err);
 
-  SVN_ERR(svn_stream_open_unique(&target, &fb->writing_file,
+  SVN_ERR(svn_stream_open_unique(&fb->tmp_file_write_stream, &fb->writing_file,
                                  target_dir, svn_io_file_del_none,
                                  fb->pool, fb->pool));
 
-  svn_txdelta_apply(source,
-                    target,
+  svn_txdelta_apply(fb->wc_file_read_stream,
+                    fb->tmp_file_write_stream,
                     fb->digest,
                     fb->local_abspath,
                     fb->pool,
@@ -535,8 +534,12 @@ file_close(void *file_baton,
   struct dir_baton_t *pb = fb->pb;
 
   if (fb->writing_file)
-    SVN_ERR(svn_io_file_rename2(fb->writing_file, fb->local_abspath,
-                                FALSE /*flush*/, scratch_pool));
+    {
+      SVN_ERR(svn_stream_close(fb->wc_file_read_stream));
+      /*SVN_ERR(svn_stream_close(fb->tmp_file_write_stream));*/
+      SVN_ERR(svn_io_file_rename2(fb->writing_file, fb->local_abspath,
+                                  FALSE /*flush*/, scratch_pool));
+    }
 
   if (text_checksum)
     {