Fix the way blobs get ingested
This commit is contained in:
parent
15eadabcf9
commit
5fa39e1752
|
@ -157,8 +157,14 @@ module Pigeon
|
|||
.map(&:collect_blobs)
|
||||
.flatten
|
||||
.uniq
|
||||
.map do |x|
|
||||
binding.pry if x.start_with?("&622PRNJ7")
|
||||
.map do |mhash|
|
||||
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
|
||||
messages
|
||||
end
|
||||
|
|
|
@ -47,7 +47,6 @@ RSpec.describe Pigeon::Message do
|
|||
|
||||
it "ingests a bundle's blobs" do
|
||||
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}`
|
||||
db.reset_database
|
||||
blobs = [
|
||||
|
@ -56,7 +55,7 @@ RSpec.describe Pigeon::Message do
|
|||
"&YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG.sha256",
|
||||
]
|
||||
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|
|
||||
expect(db.have_blob?(h)).to be true
|
||||
expect(db.get_blob(h)).to be_kind_of(String)
|
||||
|
|
Loading…
Reference in New Issue