Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't sort gems every time you add one

geminabox is basically unusable with large gem collections.
This helps to relieve that by only sorting GemVersionCollection once
upon initialization, instead of every time a gem is added.
  • Loading branch information...
commit a6f3ac9ae950ff0e1bfed8891de0798e8b11e681 1 parent cd9fdc4
@natw natw authored
Showing with 8 additions and 4 deletions.
  1. +3 −3 lib/geminabox.rb
  2. +5 −1 lib/geminabox/gem_version_collection.rb
View
6 lib/geminabox.rb
@@ -123,14 +123,14 @@ def fixup_bundler_rubygems!
error_response(200, "Ignoring upload, you uploaded the same thing previously.")
end
end
-
+
atomic_write(dest_filename) do |f|
while blk = tmpfile.read(65536)
f << blk
end
end
reindex
-
+
if api_request?
"Gem #{gem_name} received and indexed."
else
@@ -211,7 +211,7 @@ def atomic_write(file_name)
temp_file.close
File.rename(temp_file.path, file_name)
end
-
+
helpers do
def spec_for(gem_name, version)
spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
View
6 lib/geminabox/gem_version_collection.rb
@@ -12,6 +12,7 @@ def size
def initialize(initial_gems=[])
@gems = []
initial_gems.each { |gemdef| self << gemdef }
+ sort!
end
def <<(version_or_def)
@@ -22,7 +23,6 @@ def <<(version_or_def)
end
@gems << version
- @gems.sort!
end
def oldest
@@ -54,6 +54,10 @@ def by_name
end
end
+ def sort!
+ @gems.sort!
+ end
+
private
def hash_of_collections
Hash.new { |h,k| h[k] = self.class.new }
Please sign in to comment.
Something went wrong with that request. Please try again.