Skip to content
Browse files

improve reloading

  • Loading branch information...
1 parent 67374bd commit ced6e1613818a32d9d0353784ce62a198883ea96 @seki committed May 2, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/drip.rb
View
7 lib/drip.rb
@@ -13,6 +13,7 @@ def initialize(pool=[], tag=[])
@pool = pool
@tag = tag
@shared = Hash.new {|h, k| h[k] = k; k}
+ @tag.each {|pair| @shared[pair[0]]}
end
attr_reader :pool, :tag
@@ -390,16 +391,18 @@ def prepare_store(dir, option={})
return ImmutableDrip.new
end
- gen = ImmutableDrip::Generator.new
Dir.mkdir(dir) rescue nil
dump = Dir.glob(File.join(dir, '*.dump')).max_by do |fn|
File.basename(fn).to_i(36)
end
if dump
pool, tag, _ = File.open(dump, 'rb') {|fp| Marshal.load(fp)}
File.unlink(dump)
+ else
+ pool = []
+ tag = []
end
- dump = false
+ gen = ImmutableDrip::Generator.new(pool, tag)
loaded = dump ? File.basename(dump).to_i(36) : 0
Dir.glob(File.join(dir, '*.log')) do |fn|
next if loaded > File.basename(fn).to_i(36)

0 comments on commit ced6e16

Please sign in to comment.
Something went wrong with that request. Please try again.