Fix the way blobs get ingested

This commit is contained in:
Netscape Navigator 2020-05-07 07:30:32 -05:00
parent 15eadabcf9
commit 5fa39e1752
2 changed files with 9 additions and 4 deletions

View File

@ -157,8 +157,14 @@ module Pigeon
.map(&:collect_blobs) .map(&:collect_blobs)
.flatten .flatten
.uniq .uniq
.map do |x| .map do |mhash|
binding.pry if x.start_with?("&622PRNJ7") rel_path = Helpers.hash2file_path(mhash)
from = File.join([file_path] + rel_path)
to = File.join([PIGEON_BLOB_PATH] + rel_path)
if (File.file?(from) && !File.file?(to))
data = File.read(from)
Helpers.write_to_disk(PIGEON_BLOB_PATH, mhash, data)
end
end end
messages messages
end end

View File

@ -47,7 +47,6 @@ RSpec.describe Pigeon::Message do
it "ingests a bundle's blobs" do it "ingests a bundle's blobs" do
puts "WARNING: This test deletes the blob dir! Fix ASAP" puts "WARNING: This test deletes the blob dir! Fix ASAP"
puts "WARNING: This bundle contains blobs, but does not reference them."
`rm -rf #{Pigeon::PIGEON_BLOB_PATH}` `rm -rf #{Pigeon::PIGEON_BLOB_PATH}`
db.reset_database db.reset_database
blobs = [ blobs = [
@ -56,7 +55,7 @@ RSpec.describe Pigeon::Message do
"&YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG.sha256", "&YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG.sha256",
] ]
db.import_bundle("./spec/fixtures/has_blobs") db.import_bundle("./spec/fixtures/has_blobs")
expect(db.all_messages.count).to eq(1) expect(db.all_messages.count).to eq(3)
blobs.map do |h| blobs.map do |h|
expect(db.have_blob?(h)).to be true expect(db.have_blob?(h)).to be true
expect(db.get_blob(h)).to be_kind_of(String) expect(db.get_blob(h)).to be_kind_of(String)