]> source.dussan.org Git - jgit.git/commitdiff
Delay inserter.flush in WalkFetchConnection 03/82303/2
authorZhen Chen <czhen@google.com>
Fri, 30 Sep 2016 19:11:46 +0000 (12:11 -0700)
committerMatthias Sohn <matthias.sohn@sap.com>
Sat, 1 Oct 2016 22:41:33 +0000 (00:41 +0200)
Spawn an ObjectReader from the ObjectInserter, so the flush can be
delayed at the end of the fetch.

Change-Id: I35fe8c8370c06c25262645202aec2b1318057c19
Signed-off-by: Zhen Chen <czhen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java

index 17edfdc4fb5945f1f9543d2f871e1e10784fb848..c90cadf7b6f1d33fc877b7f143dffb57b583f03f 100644 (file)
@@ -195,7 +195,7 @@ class WalkFetchConnection extends BaseFetchConnection {
                local = wt.local;
                objCheck = wt.getObjectChecker();
                inserter = local.newObjectInserter();
-               reader = local.newObjectReader();
+               reader = inserter.newReader();
 
                remotes = new ArrayList<WalkRemoteObjectDatabase>();
                remotes.add(w);
@@ -240,6 +240,12 @@ class WalkFetchConnection extends BaseFetchConnection {
                                downloadObject(monitor, id);
                        process(id);
                }
+
+               try {
+                       inserter.flush();
+               } catch (IOException e) {
+                       throw new TransportException(e.getMessage(), e);
+               }
        }
 
        public Collection<PackLock> getPackLocks() {
@@ -652,7 +658,6 @@ class WalkFetchConnection extends BaseFetchConnection {
                                        Constants.typeString(type),
                                        Integer.valueOf(compressed.length)));
                }
-               inserter.flush();
        }
 
        private Collection<WalkRemoteObjectDatabase> expandOneAlternate(
@@ -883,7 +888,6 @@ class WalkFetchConnection extends BaseFetchConnection {
                        PackLock lock = parser.parse(monitor);
                        if (lock != null)
                                packLocks.add(lock);
-                       inserter.flush();
                }
        }
 }