Show More
@@ -118,7 +118,7 b' def lfs_objects_batch(request):' | |||||
118 | obj_href = request.route_url('lfs_objects_oid', repo=repo, oid=oid) |
|
118 | obj_href = request.route_url('lfs_objects_oid', repo=repo, oid=oid) | |
119 | obj_verify_href = request.route_url('lfs_objects_verify', repo=repo) |
|
119 | obj_verify_href = request.route_url('lfs_objects_verify', repo=repo) | |
120 | store = LFSOidStore( |
|
120 | store = LFSOidStore( | |
121 |
|
|
121 | oid, repo, store_location=request.registry.git_lfs_store_path) | |
122 | handler = OidHandler( |
|
122 | handler = OidHandler( | |
123 | store, repo, auth, oid, obj_size, obj_data, |
|
123 | store, repo, auth, oid, obj_size, obj_data, | |
124 | obj_href, obj_verify_href) |
|
124 | obj_href, obj_verify_href) | |
@@ -146,7 +146,7 b' def lfs_objects_oid_upload(request):' | |||||
146 | repo = request.matchdict.get('repo') |
|
146 | repo = request.matchdict.get('repo') | |
147 | oid = request.matchdict.get('oid') |
|
147 | oid = request.matchdict.get('oid') | |
148 | store = LFSOidStore( |
|
148 | store = LFSOidStore( | |
149 |
|
|
149 | oid, repo, store_location=request.registry.git_lfs_store_path) | |
150 | engine = store.get_engine(mode='wb') |
|
150 | engine = store.get_engine(mode='wb') | |
151 | log.debug('LFS: starting chunked write of LFS oid: %s to storage', oid) |
|
151 | log.debug('LFS: starting chunked write of LFS oid: %s to storage', oid) | |
152 | with engine as f: |
|
152 | with engine as f: | |
@@ -161,7 +161,7 b' def lfs_objects_oid_download(request):' | |||||
161 | oid = request.matchdict.get('oid') |
|
161 | oid = request.matchdict.get('oid') | |
162 |
|
162 | |||
163 | store = LFSOidStore( |
|
163 | store = LFSOidStore( | |
164 |
|
|
164 | oid, repo, store_location=request.registry.git_lfs_store_path) | |
165 | if not store.has_oid(): |
|
165 | if not store.has_oid(): | |
166 | log.debug('LFS: oid %s does not exists in store', oid) |
|
166 | log.debug('LFS: oid %s does not exists in store', oid) | |
167 | return write_response_error( |
|
167 | return write_response_error( | |
@@ -188,8 +188,8 b' def lfs_objects_verify(request):' | |||||
188 | return write_response_error( |
|
188 | return write_response_error( | |
189 | HTTPBadRequest, 'missing oid and size in request data') |
|
189 | HTTPBadRequest, 'missing oid and size in request data') | |
190 |
|
190 | |||
191 |
store = LFSOidStore( |
|
191 | store = LFSOidStore( | |
192 |
|
|
192 | oid, repo, store_location=request.registry.git_lfs_store_path) | |
193 | if not store.has_oid(): |
|
193 | if not store.has_oid(): | |
194 | log.debug('LFS: oid %s does not exists in store', oid) |
|
194 | log.debug('LFS: oid %s does not exists in store', oid) | |
195 | return write_response_error( |
|
195 | return write_response_error( |
@@ -106,11 +106,10 b' class OidHandler(object):' | |||||
106 |
|
106 | |||
107 | class LFSOidStore(object): |
|
107 | class LFSOidStore(object): | |
108 |
|
108 | |||
109 |
def __init__(self, |
|
109 | def __init__(self, oid, repo, store_location=None): | |
110 | self._store = store_location or self.get_default_store() |
|
|||
111 | self.oid = oid |
|
110 | self.oid = oid | |
112 | self.repo = repo |
|
111 | self.repo = repo | |
113 |
self.store_path = |
|
112 | self.store_path = store_location or self.get_default_store() | |
114 | self.tmp_oid_path = os.path.join(self.store_path, oid + '.tmp') |
|
113 | self.tmp_oid_path = os.path.join(self.store_path, oid + '.tmp') | |
115 | self.oid_path = os.path.join(self.store_path, oid) |
|
114 | self.oid_path = os.path.join(self.store_path, oid) | |
116 | self.fd = None |
|
115 | self.fd = None | |
@@ -164,4 +163,4 b' class LFSOidStore(object):' | |||||
164 | oid = os.path.join(self.store_path, self.oid) |
|
163 | oid = os.path.join(self.store_path, self.oid) | |
165 | size = os.stat(oid).st_size |
|
164 | size = os.stat(oid).st_size | |
166 |
|
165 | |||
167 | return size No newline at end of file |
|
166 | return size |
@@ -106,7 +106,8 b' class TestLFSApplication(object):' | |||||
106 |
|
106 | |||
107 | def test_app_batch_api_download(self, git_lfs_app, http_auth): |
|
107 | def test_app_batch_api_download(self, git_lfs_app, http_auth): | |
108 | oid = '456' |
|
108 | oid = '456' | |
109 |
oid_path = os.path.join(git_lfs_app._store, |
|
109 | oid_path = os.path.join(git_lfs_app._store, oid) | |
|
110 | if not os.path.isdir(os.path.dirname(oid_path)): | |||
110 | os.makedirs(os.path.dirname(oid_path)) |
|
111 | os.makedirs(os.path.dirname(oid_path)) | |
111 | with open(oid_path, 'wb') as f: |
|
112 | with open(oid_path, 'wb') as f: | |
112 | f.write('OID_CONTENT') |
|
113 | f.write('OID_CONTENT') | |
@@ -172,7 +173,8 b' class TestLFSApplication(object):' | |||||
172 |
|
173 | |||
173 | def test_app_verify_api_size_mismatch(self, git_lfs_app): |
|
174 | def test_app_verify_api_size_mismatch(self, git_lfs_app): | |
174 | oid = 'existing' |
|
175 | oid = 'existing' | |
175 |
oid_path = os.path.join(git_lfs_app._store, |
|
176 | oid_path = os.path.join(git_lfs_app._store, oid) | |
|
177 | if not os.path.isdir(os.path.dirname(oid_path)): | |||
176 | os.makedirs(os.path.dirname(oid_path)) |
|
178 | os.makedirs(os.path.dirname(oid_path)) | |
177 | with open(oid_path, 'wb') as f: |
|
179 | with open(oid_path, 'wb') as f: | |
178 | f.write('OID_CONTENT') |
|
180 | f.write('OID_CONTENT') | |
@@ -187,7 +189,8 b' class TestLFSApplication(object):' | |||||
187 |
|
189 | |||
188 | def test_app_verify_api(self, git_lfs_app): |
|
190 | def test_app_verify_api(self, git_lfs_app): | |
189 | oid = 'existing' |
|
191 | oid = 'existing' | |
190 |
oid_path = os.path.join(git_lfs_app._store, |
|
192 | oid_path = os.path.join(git_lfs_app._store, oid) | |
|
193 | if not os.path.isdir(os.path.dirname(oid_path)): | |||
191 | os.makedirs(os.path.dirname(oid_path)) |
|
194 | os.makedirs(os.path.dirname(oid_path)) | |
192 | with open(oid_path, 'wb') as f: |
|
195 | with open(oid_path, 'wb') as f: | |
193 | f.write('OID_CONTENT') |
|
196 | f.write('OID_CONTENT') | |
@@ -210,7 +213,8 b' class TestLFSApplication(object):' | |||||
210 |
|
213 | |||
211 | def test_app_download_api(self, git_lfs_app): |
|
214 | def test_app_download_api(self, git_lfs_app): | |
212 | oid = 'existing' |
|
215 | oid = 'existing' | |
213 |
oid_path = os.path.join(git_lfs_app._store, |
|
216 | oid_path = os.path.join(git_lfs_app._store, oid) | |
|
217 | if not os.path.isdir(os.path.dirname(oid_path)): | |||
214 | os.makedirs(os.path.dirname(oid_path)) |
|
218 | os.makedirs(os.path.dirname(oid_path)) | |
215 | with open(oid_path, 'wb') as f: |
|
219 | with open(oid_path, 'wb') as f: | |
216 | f.write('OID_CONTENT') |
|
220 | f.write('OID_CONTENT') | |
@@ -228,6 +232,6 b' class TestLFSApplication(object):' | |||||
228 | assert response.json == {u'upload': u'ok'} |
|
232 | assert response.json == {u'upload': u'ok'} | |
229 |
|
233 | |||
230 | # verify that we actually wrote that OID |
|
234 | # verify that we actually wrote that OID | |
231 |
oid_path = os.path.join(git_lfs_app._store, |
|
235 | oid_path = os.path.join(git_lfs_app._store, oid) | |
232 | assert os.path.isfile(oid_path) |
|
236 | assert os.path.isfile(oid_path) | |
233 | assert 'CONTENT' == open(oid_path).read() |
|
237 | assert 'CONTENT' == open(oid_path).read() |
@@ -24,7 +24,7 b' from vcsserver.git_lfs.lib import OidHan' | |||||
24 | def lfs_store(tmpdir): |
|
24 | def lfs_store(tmpdir): | |
25 | repo = 'test' |
|
25 | repo = 'test' | |
26 | oid = '123456789' |
|
26 | oid = '123456789' | |
27 |
store = LFSOidStore(repo=repo |
|
27 | store = LFSOidStore(oid=oid, repo=repo, store_location=str(tmpdir)) | |
28 | return store |
|
28 | return store | |
29 |
|
29 | |||
30 |
|
30 | |||
@@ -66,8 +66,9 b' class TestOidHandler(object):' | |||||
66 |
|
66 | |||
67 | def test_download_oid(self, oid_handler): |
|
67 | def test_download_oid(self, oid_handler): | |
68 | store = oid_handler.get_store() |
|
68 | store = oid_handler.get_store() | |
|
69 | if not os.path.isdir(os.path.dirname(store.oid_path)): | |||
|
70 | os.makedirs(os.path.dirname(store.oid_path)) | |||
69 |
|
71 | |||
70 | os.makedirs(os.path.dirname(store.oid_path)) |
|
|||
71 | with open(store.oid_path, 'wb') as f: |
|
72 | with open(store.oid_path, 'wb') as f: | |
72 | f.write('CONTENT') |
|
73 | f.write('CONTENT') | |
73 |
|
74 | |||
@@ -81,8 +82,9 b' class TestOidHandler(object):' | |||||
81 |
|
82 | |||
82 | def test_upload_oid_that_exists(self, oid_handler): |
|
83 | def test_upload_oid_that_exists(self, oid_handler): | |
83 | store = oid_handler.get_store() |
|
84 | store = oid_handler.get_store() | |
|
85 | if not os.path.isdir(os.path.dirname(store.oid_path)): | |||
|
86 | os.makedirs(os.path.dirname(store.oid_path)) | |||
84 |
|
87 | |||
85 | os.makedirs(os.path.dirname(store.oid_path)) |
|
|||
86 | with open(store.oid_path, 'wb') as f: |
|
88 | with open(store.oid_path, 'wb') as f: | |
87 | f.write('CONTENT') |
|
89 | f.write('CONTENT') | |
88 |
|
90 |
General Comments 0
You need to be logged in to leave comments.
Login now