geminabox 0.13.7 → 0.13.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of geminabox might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/geminabox.rb +0 -1
- data/lib/geminabox/server.rb +23 -15
- data/lib/geminabox/version.rb +1 -1
- data/lib/geminabox_client.rb +6 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eaa4ca96116f65f67fbd223581a5172bc96cc19
|
4
|
+
data.tar.gz: da0a1c599120be2e2ed36e157202df0e8ebacf24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d101371f803f98e6571bccf297758d8516dc22a2077f3c0875b344141ce9490c3282f9e130afc6eb858486314cfa3a426c6ad9b9f8da6dbd434227a4ce6a8226
|
7
|
+
data.tar.gz: c9fd1589eacc2d1f81c461dc10cfce27ffda756295c01a54879cb8dc2f847ca353a274920ad03eaf86d8acb149ec228c0578cccadd1f0ac84e2098fc8ff1b87e
|
data/lib/geminabox.rb
CHANGED
data/lib/geminabox/server.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'reentrant_flock'
|
2
|
+
|
1
3
|
module Geminabox
|
2
4
|
|
3
5
|
class Server < Sinatra::Base
|
@@ -65,11 +67,11 @@ module Geminabox
|
|
65
67
|
indexer.update_index
|
66
68
|
updated_gemspecs.each { |gem| dependency_cache.flush_key(gem.name) }
|
67
69
|
rescue Errno::ENOENT
|
68
|
-
reindex(:force_rebuild)
|
70
|
+
with_rlock { reindex(:force_rebuild) }
|
69
71
|
rescue => e
|
70
72
|
puts "#{e.class}:#{e.message}"
|
71
73
|
puts e.backtrace.join("\n")
|
72
|
-
reindex(:force_rebuild)
|
74
|
+
with_rlock { reindex(:force_rebuild) }
|
73
75
|
end
|
74
76
|
end
|
75
77
|
rescue Gem::SystemExitException
|
@@ -82,8 +84,22 @@ module Geminabox
|
|
82
84
|
def dependency_cache
|
83
85
|
@dependency_cache ||= Geminabox::DiskCache.new(File.join(data, "_cache"))
|
84
86
|
end
|
85
|
-
end
|
86
87
|
|
88
|
+
def with_rlock(&block)
|
89
|
+
file_class.open(settings.lockfile, File::RDWR | File::CREAT) do |f|
|
90
|
+
ReentrantFlock.synchronize(f, File::LOCK_EX | File::LOCK_NB, &block)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# This method provides a test hook, as stubbing File is painful...
|
95
|
+
def file_class
|
96
|
+
@file_class ||= File
|
97
|
+
end
|
98
|
+
|
99
|
+
def file_class=(klass)
|
100
|
+
@file_class = klass
|
101
|
+
end
|
102
|
+
end
|
87
103
|
|
88
104
|
|
89
105
|
before do
|
@@ -185,21 +201,13 @@ module Geminabox
|
|
185
201
|
private
|
186
202
|
|
187
203
|
def serialize_update(&block)
|
188
|
-
|
189
|
-
rescue AlreadyLocked
|
204
|
+
with_rlock(&block)
|
205
|
+
rescue ReentrantFlock::AlreadyLocked
|
190
206
|
halt 503, { 'Retry-After' => settings.retry_interval }, 'Repository lock is held by another process'
|
191
207
|
end
|
192
208
|
|
193
|
-
def
|
194
|
-
|
195
|
-
raise AlreadyLocked unless f.flock(File::LOCK_EX | File::LOCK_NB)
|
196
|
-
yield
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# This method provides a test hook, as stubbing File is painful...
|
201
|
-
def file_class
|
202
|
-
File
|
209
|
+
def with_rlock(&block)
|
210
|
+
self.class.with_rlock(&block)
|
203
211
|
end
|
204
212
|
|
205
213
|
def handle_incoming_gem(gem)
|
data/lib/geminabox/version.rb
CHANGED
data/lib/geminabox_client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'uri'
|
2
|
+
require 'cgi'
|
2
3
|
require 'geminabox'
|
3
4
|
|
4
5
|
class GeminaboxClient
|
@@ -12,7 +13,8 @@ class GeminaboxClient
|
|
12
13
|
|
13
14
|
def extract_username_and_password_from_url!(url)
|
14
15
|
uri = URI.parse(url.to_s)
|
15
|
-
@username
|
16
|
+
@username = CGI.unescape(uri.user) if uri.user
|
17
|
+
@password = CGI.unescape(uri.password) if uri.password
|
16
18
|
uri.user = uri.password = nil
|
17
19
|
uri.path = uri.path + "/" unless uri.path.end_with?("/")
|
18
20
|
@url = uri.to_s
|
@@ -39,7 +41,9 @@ end
|
|
39
41
|
|
40
42
|
module GeminaboxClient::GemLocator
|
41
43
|
def find_gem(dir)
|
42
|
-
|
44
|
+
gemspec_path = Dir.glob(File.join(dir, "*.gemspec")).first
|
45
|
+
gemspec = Gem::Specification::load(gemspec_path)
|
46
|
+
gemname = gemspec.name
|
43
47
|
glob_matcher = "{pkg/,}#{gemname}-*.gem"
|
44
48
|
latest_gem_for(gemname, Dir.glob(glob_matcher)) or raise Gem::CommandLineError, NO_GEM_PROVIDED_ERROR_MESSAGE
|
45
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geminabox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lea
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-09-
|
14
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sinatra
|
@@ -83,6 +83,20 @@ dependencies:
|
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: reentrant_flock
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
86
100
|
description: A sinatra based gem hosting app, with client side gem push style functionality.
|
87
101
|
email:
|
88
102
|
- contrib@tomlea.co.uk
|