You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2017/05/25 10:55:20 UTC

svn commit: r1796143 - /subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c

Author: stefan2
Date: Thu May 25 10:55:20 2017
New Revision: 1796143

URL: http://svn.apache.org/viewvc?rev=1796143&view=rev
Log:
Fix the corruption introduced by r1794536.

* subversion/libsvn_fs_fs/transaction.c
  (write_container_rep,
   write_container_delta_rep): If we don't find a matching OLD_REP,
                               we must *always* fall through to adding
                               the new representation.

Modified:
    subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c?rev=1796143&r1=1796142&r2=1796143&view=diff
==============================================================================
--- subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/1.9.x-fix-fsfs/subversion/libsvn_fs_fs/transaction.c Thu May 25 10:55:20 2017
@@ -2618,6 +2618,7 @@ write_container_rep(representation_t *re
   struct write_container_baton *whb;
   svn_checksum_ctx_t *fnv1a_checksum_ctx;
   apr_off_t offset = 0;
+  svn_fs_fs__p2l_entry_t entry;
 
   SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
 
@@ -2660,30 +2661,27 @@ write_container_rep(representation_t *re
 
           /* Use the old rep for this content. */
           memcpy(rep, old_rep, sizeof (*rep));
+          return SVN_NO_ERROR;
         }
     }
-  else
-    {
-      svn_fs_fs__p2l_entry_t entry;
 
-      /* Write out our cosmetic end marker. */
-      SVN_ERR(svn_stream_puts(whb->stream, "ENDREP\n"));
+  /* Write out our cosmetic end marker. */
+  SVN_ERR(svn_stream_puts(whb->stream, "ENDREP\n"));
 
-      SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
-                                  offset, scratch_pool));
+  SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
+                              offset, scratch_pool));
 
-      entry.offset = offset;
-      SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
-      entry.size = offset - entry.offset;
-      entry.type = item_type;
-      entry.item.revision = SVN_INVALID_REVNUM;
-      entry.item.number = rep->item_index;
-      SVN_ERR(fnv1a_checksum_finalize(&entry.fnv1_checksum,
-                                      fnv1a_checksum_ctx,
-                                      scratch_pool));
+  entry.offset = offset;
+  SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+  entry.size = offset - entry.offset;
+  entry.type = item_type;
+  entry.item.revision = SVN_INVALID_REVNUM;
+  entry.item.number = rep->item_index;
+  SVN_ERR(fnv1a_checksum_finalize(&entry.fnv1_checksum,
+                                  fnv1a_checksum_ctx,
+                                  scratch_pool));
 
-      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
-    }
+  SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2725,6 +2723,7 @@ write_container_delta_rep(representation
   svn_checksum_ctx_t *fnv1a_checksum_ctx;
   svn_stream_t *source;
   svn_fs_fs__rep_header_t header = { 0 };
+  svn_fs_fs__p2l_entry_t entry;
 
   apr_off_t rep_end = 0;
   apr_off_t delta_start = 0;
@@ -2807,30 +2806,27 @@ write_container_delta_rep(representation
 
           /* Use the old rep for this content. */
           memcpy(rep, old_rep, sizeof (*rep));
+          return SVN_NO_ERROR;
         }
     }
-  else
-    {
-      svn_fs_fs__p2l_entry_t entry;
 
-      /* Write out our cosmetic end marker. */
-      SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
+  /* Write out our cosmetic end marker. */
+  SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
 
-      SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
-                                  offset, scratch_pool));
+  SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
+                              offset, scratch_pool));
 
-      entry.offset = offset;
-      SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
-      entry.size = offset - entry.offset;
-      entry.type = item_type;
-      entry.item.revision = SVN_INVALID_REVNUM;
-      entry.item.number = rep->item_index;
-      SVN_ERR(fnv1a_checksum_finalize(&entry.fnv1_checksum,
-                                      fnv1a_checksum_ctx,
-                                      scratch_pool));
+  entry.offset = offset;
+  SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+  entry.size = offset - entry.offset;
+  entry.type = item_type;
+  entry.item.revision = SVN_INVALID_REVNUM;
+  entry.item.number = rep->item_index;
+  SVN_ERR(fnv1a_checksum_finalize(&entry.fnv1_checksum,
+                                  fnv1a_checksum_ctx,
+                                  scratch_pool));
 
-      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
-    }
+  SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
 
   return SVN_NO_ERROR;
 }