get_nn_partition returns an empty array if no key has been indexed.

remotes/1708105384931250775/master
Luka Vandervelden 2019-11-20 00:32:32 +01:00
parent 4858e5c4dc
commit 7a46fa3872
2 changed files with 7 additions and 0 deletions

View File

@ -80,6 +80,9 @@ class FS::Hash(K, V)
r_value = Array(V).new
partition_directory = "#{dir_path_nn name}/#{key}"
return r_value unless Dir.exists? partition_directory
Dir.each_child partition_directory do |child|
r_value << V.from_json ::File.read "#{partition_directory}/#{child}"
end

View File

@ -55,3 +55,7 @@ s.to_h.size.times do
pp! s.get_nn_partition("tags", "shiratsuyu").map &.title
end
puts "Testing get_nn_partition on unknown entries."
pp! s.get_nn_partition("tags", "kaga").map &.title