Show More
@@ -227,20 +227,27 b' class _gitlfsremote(object):' | |||||
227 | % rawjson) |
|
227 | % rawjson) | |
228 | return response |
|
228 | return response | |
229 |
|
229 | |||
230 | def _checkforservererror(self, pointers, responses): |
|
230 | def _checkforservererror(self, pointers, responses, action): | |
231 | """Scans errors from objects |
|
231 | """Scans errors from objects | |
232 |
|
232 | |||
233 | Returns LfsRemoteError if any objects has an error""" |
|
233 | Returns LfsRemoteError if any objects has an error""" | |
234 | for response in responses: |
|
234 | for response in responses: | |
235 | error = response.get('error') |
|
235 | # The server should return 404 when objects cannot be found. Some | |
236 | if error: |
|
236 | # server implementation (ex. lfs-test-server) does not set "error" | |
|
237 | # but just removes "download" from "actions". Treat that case | |||
|
238 | # as the same as 404 error. | |||
|
239 | notfound = (response.get('error', {}).get('code') == 404 | |||
|
240 | or (action == 'download' | |||
|
241 | and action not in response.get('actions', []))) | |||
|
242 | if notfound: | |||
237 | ptrmap = {p.oid(): p for p in pointers} |
|
243 | ptrmap = {p.oid(): p for p in pointers} | |
238 | p = ptrmap.get(response['oid'], None) |
|
244 | p = ptrmap.get(response['oid'], None) | |
239 |
if |
|
245 | if p: | |
240 | filename = getattr(p, 'filename', 'unknown') |
|
246 | filename = getattr(p, 'filename', 'unknown') | |
241 | raise LfsRemoteError( |
|
247 | raise LfsRemoteError( | |
242 | _(('LFS server error. Remote object ' |
|
248 | _(('LFS server error. Remote object ' | |
243 | 'for "%s" not found: %r')) % (filename, response)) |
|
249 | 'for "%s" not found: %r')) % (filename, response)) | |
|
250 | if 'error' in response: | |||
244 | raise LfsRemoteError(_('LFS server error: %r') % response) |
|
251 | raise LfsRemoteError(_('LFS server error: %r') % response) | |
245 |
|
252 | |||
246 | def _extractobjects(self, response, pointers, action): |
|
253 | def _extractobjects(self, response, pointers, action): | |
@@ -252,21 +259,11 b' class _gitlfsremote(object):' | |||||
252 | """ |
|
259 | """ | |
253 | # Scan errors from objects - fail early |
|
260 | # Scan errors from objects - fail early | |
254 | objects = response.get('objects', []) |
|
261 | objects = response.get('objects', []) | |
255 | self._checkforservererror(pointers, objects) |
|
262 | self._checkforservererror(pointers, objects, action) | |
256 |
|
263 | |||
257 | # Filter objects with given action. Practically, this skips uploading |
|
264 | # Filter objects with given action. Practically, this skips uploading | |
258 | # objects which exist in the server. |
|
265 | # objects which exist in the server. | |
259 | filteredobjects = [o for o in objects if action in o.get('actions', [])] |
|
266 | filteredobjects = [o for o in objects if action in o.get('actions', [])] | |
260 | # But for downloading, we want all objects. Therefore missing objects |
|
|||
261 | # should be considered an error. |
|
|||
262 | if action == 'download': |
|
|||
263 | if len(filteredobjects) < len(objects): |
|
|||
264 | missing = [o.get('oid', '?') |
|
|||
265 | for o in objects |
|
|||
266 | if action not in o.get('actions', [])] |
|
|||
267 | raise LfsRemoteError( |
|
|||
268 | _('LFS server claims required objects do not exist:\n%s') |
|
|||
269 | % '\n'.join(missing)) |
|
|||
270 |
|
267 | |||
271 | return filteredobjects |
|
268 | return filteredobjects | |
272 |
|
269 |
@@ -160,12 +160,12 b' Check error message when the remote miss' | |||||
160 | $ rm -rf .hg/store/lfs |
|
160 | $ rm -rf .hg/store/lfs | |
161 | $ rm -rf `hg config lfs.usercache` |
|
161 | $ rm -rf `hg config lfs.usercache` | |
162 | $ hg update -C '.^' |
|
162 | $ hg update -C '.^' | |
163 | abort: LFS server claims required objects do not exist: |
|
163 | abort: LFS server error. Remote object for "b" not found:(.*)! (re) | |
164 | 8e6ea5f6c066b44a0efa43bcce86aea73f17e6e23f0663df0251e7524e140a13! |
|
|||
165 | [255] |
|
164 | [255] | |
166 |
|
165 | |||
167 | Check error message when object does not exist: |
|
166 | Check error message when object does not exist: | |
168 |
|
167 | |||
|
168 | $ cd $TESTTMP | |||
169 | $ hg init test && cd test |
|
169 | $ hg init test && cd test | |
170 | $ echo "[extensions]" >> .hg/hgrc |
|
170 | $ echo "[extensions]" >> .hg/hgrc | |
171 | $ echo "lfs=" >> .hg/hgrc |
|
171 | $ echo "lfs=" >> .hg/hgrc | |
@@ -183,7 +183,22 b' Check error message when object does not' | |||||
183 | x-is-binary 0 |
|
183 | x-is-binary 0 | |
184 | $ cd .. |
|
184 | $ cd .. | |
185 | $ rm -rf `hg config lfs.usercache` |
|
185 | $ rm -rf `hg config lfs.usercache` | |
186 | $ hg --config 'lfs.url=https://dewey-lfs.vip.facebook.com/lfs' clone test test2 |
|
186 | ||
|
187 | (Restart the server in a different location so it no longer has the content) | |||
|
188 | ||||
|
189 | $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS | |||
|
190 | $ rm $DAEMON_PIDS | |||
|
191 | $ mkdir $TESTTMP/lfs-server2 | |||
|
192 | $ cd $TESTTMP/lfs-server2 | |||
|
193 | #if no-windows | |||
|
194 | $ lfs-test-server &> lfs-server.log & | |||
|
195 | $ echo $! >> $DAEMON_PIDS | |||
|
196 | #else | |||
|
197 | $ $PYTHON $TESTTMP/spawn.py >> $DAEMON_PIDS | |||
|
198 | #endif | |||
|
199 | ||||
|
200 | $ cd $TESTTMP | |||
|
201 | $ hg clone test test2 | |||
187 | updating to branch default |
|
202 | updating to branch default | |
188 | abort: LFS server error. Remote object for "a" not found:(.*)! (re) |
|
203 | abort: LFS server error. Remote object for "a" not found:(.*)! (re) | |
189 | [255] |
|
204 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now