Works, but needs test to verify

This commit is contained in:
Netscape Navigator 2020-04-25 10:31:32 -05:00
parent 33429e3f0b
commit be21697f7c
9 changed files with 3 additions and 18 deletions

View File

@ -226,7 +226,6 @@ module Pigeon
path
end
full_path = File.join(dir, file_name)
raise "HERE!" if dir.include?(".")
unless File.file?(full_path)
FileUtils.makedirs(dir)
File.write(full_path, data)

View File

@ -136,14 +136,8 @@ module Pigeon
.flatten
.uniq
.map do |mhash|
hash2filepath = Helpers.hash2file_path(mhash)
blob_path = File.join(file_path, hash2filepath)
blob = get_blob(mhash)
puts "=== EXPORT"
puts " blob_path: #{blob_path}"
puts " mhash: #{mhash}"
puts " blob: #{blob.length} bytes"
Helpers.write_to_disk(blob_path, mhash, blob)
Helpers.write_to_disk(file_path, mhash, blob)
end
# Render messages for all peers.

View File

@ -47,13 +47,8 @@ RSpec.describe Pigeon::Message do
it "ingests a bundle's blobs" do
db.reset_database
db.add_message(db.add_blob(File.read("a.gif")), {
db.add_blob(File.read("b.gif")) => db.add_blob(File.read("c.gif")),
})
db.export_bundle("./spec/fixtures/has_blobs")
warn("The directory structure is not correct.")
exit(1)
db.import_bundle("./spec/fixtures/has_blobs")
expect(db.all_messages.count).to eq(0)
expect(db.all_messages.count).to eq(1)
warn("TODO: Write better tests")
end
end