From 2d7c1b2f266e869126ab51b798ed0269fa40ef8e Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Sat, 25 Apr 2020 09:47:58 -0500 Subject: [PATCH] Test updates --- lib/pigeon.rb | 7 ++++++- lib/pigeon/database.rb | 6 ++++-- pigeon.db | Bin 997 -> 0 bytes spec/pigeon/bundle_spec.rb | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 pigeon.db diff --git a/lib/pigeon.rb b/lib/pigeon.rb index 5c85cde..d2a973d 100644 --- a/lib/pigeon.rb +++ b/lib/pigeon.rb @@ -208,7 +208,12 @@ module Pigeon end def self.mkdir_p(path) - FileUtils.makedirs(path) unless Dir.exists?(path) + if Dir.exists?(path) + FileUtils.makedirs(path) + else + end + rescue => x + binding.pry end def self.write_to_disk(base_path, mhash, data) diff --git a/lib/pigeon/database.rb b/lib/pigeon/database.rb index 6f64830..31d2d12 100644 --- a/lib/pigeon/database.rb +++ b/lib/pigeon/database.rb @@ -110,8 +110,10 @@ module Pigeon .flatten .uniq .map do |mhash| - blob_path = File.join(file_path, Helpers.hash2file_path(mhash)) - Helpers.write_to_disk(blob_path, mhash, get_blob(mhash)) + hash2filepath = Helpers.hash2file_path(mhash) + blob_path = File.join(file_path, hash2filepath) + blob = get_blob(mhash) + Helpers.write_to_disk(blob_path, mhash, blob) if blob end # Render messages for all peers. diff --git a/pigeon.db b/pigeon.db deleted file mode 100644 index 639f1ba0c46cc2cab2a38bcf82c94887ef8d4b4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 997 zcmb`GyKdA#6oykECnP~Z0;Qp|l$5Kn$Ct6w*lUlk8snSnwHt7<&aO#zy;^$_QIwb9 z4d`g-LD2C4c?76Z@dQ-Zi&hFXDbE?rH~;z1KaX~<_iTFq^s+v?D94mc;kcG}qOzsr zU1eG{)0-{BrXQcx^K8Hu z|9pM%@r`KO^nry{eK1}Y=WTxl*z~hm*)+wZYzAlbYQFAXQ#L(RgusWMYifWH#$w#W z*8(TNdge&P!o*->H#HKE;E};VDUL^?B!WRXW_g~GdUn-Oo^0T2v0Xzw(ioldg-{*w zLBipL^(8)a!x$r=ONqm>z>yqD%ZbJFhA&uF3Nv%iObeD5dPprl_p3=+&t;kX6}~U; zE5)jv*2`Lcu{jINS>2ZQxSY3Ddqv3y%4~JnR=tA{F8>Jp2s0P@#EQaVR za5Oe|1=a(^Gk9!b9FHOhIFLmoAqWoxHR6zYf1)12dWeGzCPRZ0!zkhS4D-1@j7b{g zAt$oXKnYBSnczY(4N^~J)%yr}PZ^hsc3N$9!Y-=$xMzxtrbPzf&D6;N3?WPq%Cjgi z*bv3OAws0Lj#A9!1Tm2qTdA1~Ubnts2C)}#`A9M}O+bK8wTMZ>L}k4$Sq|qD!N>zYQHkkk zE)Y1K4Tq`9C03@!v4ONyaD8MUOCp}8f=*pExt}nbKHTJMaC-G>ZNVmJ`hVqj0D8^? W#MP#E7iGC@*3mtosFUsP1OEZt6c?xf diff --git a/spec/pigeon/bundle_spec.rb b/spec/pigeon/bundle_spec.rb index 5df706f..637b726 100644 --- a/spec/pigeon/bundle_spec.rb +++ b/spec/pigeon/bundle_spec.rb @@ -47,8 +47,8 @@ RSpec.describe Pigeon::Message do it "ingests a bundle's blobs" do db.reset_database - db.add_message(db.add_blob("a.gif"), { - db.add_blob("b.gif") => db.add_blob("c.gif"), + 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") STDERR.puts("The directory structure is not correct.")