Show More
@@ -168,6 +168,20 class local(object): | |||||
168 |
|
168 | |||
169 | self._linktousercache(oid) |
|
169 | self._linktousercache(oid) | |
170 |
|
170 | |||
|
171 | def linkfromusercache(self, oid): | |||
|
172 | """Link blobs found in the user cache into this store. | |||
|
173 | ||||
|
174 | The server module needs to do this when it lets the client know not to | |||
|
175 | upload the blob, to ensure it is always available in this store. | |||
|
176 | Normally this is done implicitly when the client reads or writes the | |||
|
177 | blob, but that doesn't happen when the server tells the client that it | |||
|
178 | already has the blob. | |||
|
179 | """ | |||
|
180 | if (not isinstance(self.cachevfs, nullvfs) | |||
|
181 | and not self.vfs.exists(oid)): | |||
|
182 | self.ui.note(_('lfs: found %s in the usercache\n') % oid) | |||
|
183 | lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid)) | |||
|
184 | ||||
171 | def _linktousercache(self, oid): |
|
185 | def _linktousercache(self, oid): | |
172 | # XXX: should we verify the content of the cache, and hardlink back to |
|
186 | # XXX: should we verify the content of the cache, and hardlink back to | |
173 | # the local store on success, but truncate, write and link on failure? |
|
187 | # the local store on success, but truncate, write and link on failure? |
@@ -204,6 +204,10 def _batchresponseobjects(req, objects, | |||||
204 | # verified as the file is streamed to the caller. |
|
204 | # verified as the file is streamed to the caller. | |
205 | try: |
|
205 | try: | |
206 | verifies = store.verify(oid) |
|
206 | verifies = store.verify(oid) | |
|
207 | if verifies and action == 'upload': | |||
|
208 | # The client will skip this upload, but make sure it remains | |||
|
209 | # available locally. | |||
|
210 | store.linkfromusercache(oid) | |||
207 | except IOError as inst: |
|
211 | except IOError as inst: | |
208 | if inst.errno != errno.ENOENT: |
|
212 | if inst.errno != errno.ENOENT: | |
209 | _logexception(req) |
|
213 | _logexception(req) |
@@ -150,6 +150,33 Blob URIs are correct when --prefix is u | |||||
150 | $LOCALIP - - [$LOGDATE$] "POST /subdir/mount/point/.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob) |
|
150 | $LOCALIP - - [$LOGDATE$] "POST /subdir/mount/point/.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob) | |
151 | $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point/.hg/lfs/objects/f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e HTTP/1.1" 200 - (glob) |
|
151 | $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point/.hg/lfs/objects/f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e HTTP/1.1" 200 - (glob) | |
152 |
|
152 | |||
|
153 | Blobs that already exist in the usercache are linked into the repo store, even | |||
|
154 | though the client doesn't send the blob. | |||
|
155 | ||||
|
156 | $ hg init server2 | |||
|
157 | $ hg --config "lfs.usercache=$TESTTMP/servercache" -R server2 serve -d \ | |||
|
158 | > -p $HGPORT --pid-file=hg.pid \ | |||
|
159 | > -A $TESTTMP/access.log -E $TESTTMP/errors.log | |||
|
160 | $ cat hg.pid >> $DAEMON_PIDS | |||
|
161 | ||||
|
162 | $ hg --config "lfs.usercache=$TESTTMP/servercache" -R cloned2 --debug \ | |||
|
163 | > push http://localhost:$HGPORT | grep '^[{} ]' | |||
|
164 | { | |||
|
165 | "objects": [ | |||
|
166 | { | |||
|
167 | "oid": "f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e" | |||
|
168 | "size": 20 | |||
|
169 | } | |||
|
170 | ] | |||
|
171 | "transfer": "basic" | |||
|
172 | } | |||
|
173 | $ find server2/.hg/store/lfs/objects | sort | |||
|
174 | server2/.hg/store/lfs/objects | |||
|
175 | server2/.hg/store/lfs/objects/f0 | |||
|
176 | server2/.hg/store/lfs/objects/f0/3217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e | |||
|
177 | $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS | |||
|
178 | $ cat $TESTTMP/errors.log | |||
|
179 | ||||
153 | $ cat >> $TESTTMP/lfsstoreerror.py <<EOF |
|
180 | $ cat >> $TESTTMP/lfsstoreerror.py <<EOF | |
154 | > import errno |
|
181 | > import errno | |
155 | > from hgext.lfs import blobstore |
|
182 | > from hgext.lfs import blobstore |
General Comments 0
You need to be logged in to leave comments.
Login now