diff --git a/lib/miga/cli/action/doctor/distances.rb b/lib/miga/cli/action/doctor/distances.rb index c7877d4..6ef0b58 100644 --- a/lib/miga/cli/action/doctor/distances.rb +++ b/lib/miga/cli/action/doctor/distances.rb @@ -141,18 +141,22 @@ def merge_bidir_tmp(tmp) end MiGA::Parallel.distribute(lower_triangle, cli[:threads]) do |cell, k, thr| cli.advance('Writing:', k, lower_triangle.size, false) if thr == 0 + done_f = File.join(tmp, "#{cell[0]}-#{cell[1]}.txt") + next if File.exist?(done_f) + fixed_ds = merge_bidir_tmp_pair(tmp, cell[0], cell[1]) - File.open(File.join(tmp, "#{cell[0]}-#{cell[1]}.txt"), 'w') do |fh| - fixed_ds.each { |ds| fh.puts ds } - end + File.open("#{done_f}.tmp", 'w') { |fh| fixed_ds.each { |ds| fh.puts ds } } + File.rename("#{done_f}.tmp", done_f) end cli.advance('Writing:', lower_triangle.size, lower_triangle.size, false) cli.say lower_triangle.map do |cell| Set.new.tap do |y| - File.open(File.join(tmp, "#{cell[0]}-#{cell[1]}.txt"), 'r') do |fh| - fh.each { |ln| y << ln.chomp } - end + file = File.join(tmp, "#{cell[0]}-#{cell[1]}.txt") + raise MiGA::Error.new( + "Expected file missing, probably due to a thread failure: #{file}" + ) unless File.exist?(file) + File.open(file, 'r') { |fh| fh.each { |ln| y << ln.chomp } } end end.inject(Set.new, :+) end diff --git a/lib/miga/version.rb b/lib/miga/version.rb index 97c242e..df17e45 100644 --- a/lib/miga/version.rb +++ b/lib/miga/version.rb @@ -12,7 +12,7 @@ module MiGA # - String indicating release status: # - rc* release candidate, not released as gem # - [0-9]+ stable release, released as gem - VERSION = [1.3, 20, 8].freeze + VERSION = [1.3, 20, 9].freeze ## # Nickname for the current major.minor version.