Show More
@@ -227,20 +227,27 b' class _gitlfsremote(object):' | |||
|
227 | 227 | % rawjson) |
|
228 | 228 | return response |
|
229 | 229 | |
|
230 | def _checkforservererror(self, pointers, responses): | |
|
230 | def _checkforservererror(self, pointers, responses, action): | |
|
231 | 231 | """Scans errors from objects |
|
232 | 232 | |
|
233 | 233 | Returns LfsRemoteError if any objects has an error""" |
|
234 | 234 | for response in responses: |
|
235 | error = response.get('error') | |
|
236 | if error: | |
|
235 | # The server should return 404 when objects cannot be found. Some | |
|
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 | 243 | ptrmap = {p.oid(): p for p in pointers} |
|
238 | 244 | p = ptrmap.get(response['oid'], None) |
|
239 |
if |
|
|
245 | if p: | |
|
240 | 246 | filename = getattr(p, 'filename', 'unknown') |
|
241 | 247 | raise LfsRemoteError( |
|
242 | 248 | _(('LFS server error. Remote object ' |
|
243 | 249 | 'for "%s" not found: %r')) % (filename, response)) |
|
250 | if 'error' in response: | |
|
244 | 251 | raise LfsRemoteError(_('LFS server error: %r') % response) |
|
245 | 252 | |
|
246 | 253 | def _extractobjects(self, response, pointers, action): |
@@ -252,21 +259,11 b' class _gitlfsremote(object):' | |||
|
252 | 259 | """ |
|
253 | 260 | # Scan errors from objects - fail early |
|
254 | 261 | objects = response.get('objects', []) |
|
255 | self._checkforservererror(pointers, objects) | |
|
262 | self._checkforservererror(pointers, objects, action) | |
|
256 | 263 | |
|
257 | 264 | # Filter objects with given action. Practically, this skips uploading |
|
258 | 265 | # objects which exist in the server. |
|
259 | 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 | 268 | return filteredobjects |
|
272 | 269 |
@@ -160,12 +160,12 b' Check error message when the remote miss' | |||
|
160 | 160 | $ rm -rf .hg/store/lfs |
|
161 | 161 | $ rm -rf `hg config lfs.usercache` |
|
162 | 162 | $ hg update -C '.^' |
|
163 | abort: LFS server claims required objects do not exist: | |
|
164 | 8e6ea5f6c066b44a0efa43bcce86aea73f17e6e23f0663df0251e7524e140a13! | |
|
163 | abort: LFS server error. Remote object for "b" not found:(.*)! (re) | |
|
165 | 164 | [255] |
|
166 | 165 | |
|
167 | 166 | Check error message when object does not exist: |
|
168 | 167 | |
|
168 | $ cd $TESTTMP | |
|
169 | 169 | $ hg init test && cd test |
|
170 | 170 | $ echo "[extensions]" >> .hg/hgrc |
|
171 | 171 | $ echo "lfs=" >> .hg/hgrc |
@@ -183,7 +183,22 b' Check error message when object does not' | |||
|
183 | 183 | x-is-binary 0 |
|
184 | 184 | $ cd .. |
|
185 | 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 | 202 | updating to branch default |
|
188 | 203 | abort: LFS server error. Remote object for "a" not found:(.*)! (re) |
|
189 | 204 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now