lsst-git-lfs-s3 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/git-lfs-s3/application.rb +51 -42
- data/lib/git-lfs-s3/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87a60c4fc9a10e630a5dd87eb4a47bdb9d9b02e3
|
4
|
+
data.tar.gz: d784db052f045fd9285c0e9521f03d0c8e3be558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d31f5b993a19bb8ffbeee5ba0e8ca481485984a8e52ef6adc56088100bdf520f58f09ff2c206af3465f381062a6976146a383e045eeab999a143193c26db85c
|
7
|
+
data.tar.gz: 02cdb618456dec8c3a57d792b6ba6e05bd0c682580642975cd37a2142076e0c0a836efaa9659b4bfb14a4cf2f08675d12a5a41f714bc59310cde4f287eec92d1
|
@@ -176,7 +176,9 @@ module GitLfsS3
|
|
176
176
|
params = indifferent_params(JSON.parse(request.body.read))
|
177
177
|
logger.debug params
|
178
178
|
if params[:operation] == 'download'
|
179
|
-
|
179
|
+
if settings.public_server
|
180
|
+
lfs_resp(download(authenticated, params))
|
181
|
+
end
|
180
182
|
elsif params[:operation] == 'upload'
|
181
183
|
if authenticated
|
182
184
|
lfs_resp(upload(authenticated, params))
|
@@ -189,28 +191,30 @@ module GitLfsS3
|
|
189
191
|
end
|
190
192
|
|
191
193
|
get "/objects/:oid", provides: 'application/vnd.git-lfs+json' do
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
194
|
+
if settings.public_server
|
195
|
+
object = object_data(params[:oid])
|
196
|
+
if object.exists?
|
197
|
+
status 200
|
198
|
+
resp = {
|
199
|
+
'oid' => params[:oid],
|
200
|
+
'size' => object.size,
|
201
|
+
'_links' => {
|
202
|
+
'self' => {
|
203
|
+
'href' => File.join(settings.server_url, 'objects', params[:oid])
|
204
|
+
},
|
205
|
+
'download' => {
|
206
|
+
'href' => object_data(params[:oid]).presigned_url(:get)
|
207
|
+
}
|
206
208
|
}
|
207
209
|
}
|
208
|
-
|
209
|
-
|
210
|
-
|
210
|
+
body MultiJson.dump(resp)
|
211
|
+
else
|
212
|
+
status 404
|
213
|
+
body MultiJson.dump({message: 'Object not found'})
|
214
|
+
end
|
211
215
|
else
|
212
|
-
status
|
213
|
-
body MultiJson.dump({message: '
|
216
|
+
status 401
|
217
|
+
body MultiJson.dump({message: 'Invalid username or password'})
|
214
218
|
end
|
215
219
|
end
|
216
220
|
|
@@ -221,33 +225,38 @@ module GitLfsS3
|
|
221
225
|
Aws::S3::Types::Grant.new(grantee: grantee, permission: "READ")
|
222
226
|
end
|
223
227
|
|
224
|
-
before do
|
225
|
-
pass if request.safe? and settings.public_server
|
226
|
-
protected!
|
227
|
-
end
|
228
|
-
|
229
228
|
post "/objects", provides: 'application/vnd.git-lfs+json' do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
229
|
+
if authorized?
|
230
|
+
logger.debug headers.inspect
|
231
|
+
service = UploadService.service_for(request.body)
|
232
|
+
logger.debug service.response
|
233
|
+
|
234
|
+
status service.status
|
235
|
+
body MultiJson.dump(service.response)
|
236
|
+
else
|
237
|
+
status 401
|
238
|
+
body MultiJson.dump({message: 'Invalid username or password'})
|
239
|
+
end
|
236
240
|
end
|
237
241
|
|
238
242
|
post '/verify', provides: 'application/vnd.git-lfs+json' do
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
if settings.public_server and settings.ceph_s3
|
245
|
-
if not object.acl.grants.include?(public_read_grant)
|
246
|
-
object.acl.put(acl: "public-read")
|
243
|
+
if authorized?
|
244
|
+
data = MultiJson.load(request.body.tap { |b| b.rewind }.read)
|
245
|
+
object = object_data(data['oid'])
|
246
|
+
if not object.exists?
|
247
|
+
status 404
|
247
248
|
end
|
248
|
-
|
249
|
-
|
250
|
-
|
249
|
+
if settings.public_server and settings.ceph_s3
|
250
|
+
if not object.acl.grants.include?(public_read_grant)
|
251
|
+
object.acl.put(acl: "public-read")
|
252
|
+
end
|
253
|
+
end
|
254
|
+
if object.size == data['size']
|
255
|
+
status 200
|
256
|
+
end
|
257
|
+
else
|
258
|
+
status 401
|
259
|
+
body MultiJson.dump({message: 'Invalid username or password'})
|
251
260
|
end
|
252
261
|
end
|
253
262
|
end
|
data/lib/git-lfs-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lsst-git-lfs-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan LeFevre
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-02-
|
12
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|