indexer: kill git_indexer_stats.data_received It's not really needed with the current code as we have EOS and the sideband's flush to tell us we're done. Keep the distinction between processed and received objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index 92d1d9e..87f48fe 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -20,7 +20,6 @@ typedef struct git_indexer_stats {
unsigned int total;
unsigned int processed;
unsigned int received;
- unsigned int data_received;
} git_indexer_stats;
diff --git a/src/fetch.c b/src/fetch.c
index 4c7e825..278ba3c 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -306,10 +306,7 @@ static int no_sideband(git_indexer_stream *idx, gitno_buffer *buf, git_off_t *by
return -1;
*bytes += recvd;
- } while(recvd > 0 && stats->data_received);
-
- if (!stats->data_received)
- giterr_set(GITERR_NET, "Early EOF while downloading packfile");
+ } while(recvd > 0);
if (git_indexer_stream_finalize(idx, stats))
return -1;
@@ -374,13 +371,10 @@ int git_fetch__download_pack(
git__free(pkt);
break;
}
- } while (!stats->data_received);
-
- if (!stats->data_received)
- giterr_set(GITERR_NET, "Early EOF while downloading packfile");
+ } while (1);
- if (git_indexer_stream_finalize(idx, stats))
- return -1;
+ if (git_indexer_stream_finalize(idx, stats) < 0)
+ goto on_error;
git_indexer_stream_free(idx);
return 0;
diff --git a/src/indexer.c b/src/indexer.c
index 719f54e..85ffb16 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -383,14 +383,6 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
stats->received++;
}
- /*
- * If we've received all of the objects and our packfile is
- * one hash beyond the end of the last object, all of the
- * packfile is here.
- */
- if (stats->received == idx->nr_objects && idx->pack->mwf.size >= idx->off + 20)
- stats->data_received = 1;
-
return 0;
on_error: