Commit 8abcce7cf104e77dbb7a4c2f6175031ea9dbab55
Fix fetch with no haves
Charles Lehner committed on 7/30/2016, 9:35:29 PMParent: e6b9c24e5ee9397fd4807d48300ea1511f41a55e
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -72,9 +72,9 @@ | ||
72 | 72 | var wants = {} |
73 | 73 | var shallows = {} |
74 | 74 | var aborted |
75 | 75 | var hasWants |
76 | - var gotWants | |
76 | + var gotWants, gotHaves | |
77 | 77 | |
78 | 78 | function readWant(abort, cb) { |
79 | 79 | if (abort) return |
80 | 80 | // read upload request (wants list) from client |
@@ -104,8 +104,14 @@ | ||
104 | 104 | // TODO: implement multi_ack_detailed |
105 | 105 | if (abort) return |
106 | 106 | readWantHave(null, function next(end, have) { |
107 | 107 | if (end === true) { |
108 | + gotHaves = true | |
109 | + if (!acked) { | |
110 | + cb(null, 'NAK') | |
111 | + } else { | |
112 | + cb(true) | |
113 | + } | |
108 | 114 | cb(true) |
109 | 115 | } else if (have.type === 'flush-pkt') { |
110 | 116 | // found no common object |
111 | 117 | if (!acked) { |
@@ -137,9 +143,10 @@ | ||
137 | 143 | sendRefs, |
138 | 144 | pull.once(''), |
139 | 145 | function (abort, cb) { |
140 | 146 | if (!gotWants) readWant(abort, cb) |
141 | - else readHave(abort, cb) | |
147 | + else if (!gotHaves) readHave(abort, cb) | |
148 | + else cb(true) | |
142 | 149 | } |
143 | 150 | ])), |
144 | 151 | |
145 | 152 | function (abort, cb) { |
Built with git-ssb-web