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