Tags should now be working as expected.

tag-rewrite
Karchnu 2024-04-26 23:26:56 +02:00
parent 7584c3acc0
commit bcfe5d44d6
3 changed files with 9 additions and 9 deletions

View File

@ -148,15 +148,15 @@ abstract class DODB::Storage(V)
end end
def new_tags(name : String, &block : Proc(V, Array(String))) def new_tags(name : String, &block : Proc(V, Array(String)))
Tags(V).new(@directory_name, name, block).tap do |tags| Tags(V).new(self, @directory_name, name, block).tap do |tags|
@indexers << tags @indexers << tags
end end
end end
def get_tags(name, key : String) def get_tags(name, key : String)
partition = @indexers.find &.name.==(name) tag = @indexers.find &.name.==(name)
partition.not_nil!.as(DODB::Tags).get name, key tag.not_nil!.as(DODB::Tags).get name, key
end end
def new_directed_graph(name : String, index : DODB::Index(V), &block : Proc(V, Array(String))) : DirectedGraph(V) def new_directed_graph(name : String, index : DODB::Index(V), &block : Proc(V, Array(String))) : DirectedGraph(V)

View File

@ -8,6 +8,7 @@ class DODB::Partition(V) < DODB::Indexer(V)
property key_proc : Proc(V, String) property key_proc : Proc(V, String)
getter storage_root : String getter storage_root : String
# Required to remove an entry in the DB.
@storage : DODB::Storage(V) @storage : DODB::Storage(V)
def initialize(@storage, @storage_root, @name, @key_proc) def initialize(@storage, @storage_root, @name, @key_proc)

View File

@ -6,7 +6,10 @@ class DODB::Tags(V) < DODB::Indexer(V)
property key_proc : Proc(V, Array(String)) property key_proc : Proc(V, Array(String))
getter storage_root : String getter storage_root : String
def initialize(@storage_root, @name, @key_proc) # Required to remove an entry in the DB.
@storage : DODB::Storage(V)
def initialize(@storage, @storage_root, @name, @key_proc)
::Dir.mkdir_p indexing_directory ::Dir.mkdir_p indexing_directory
end end
@ -31,10 +34,7 @@ class DODB::Tags(V) < DODB::Indexer(V)
indices.each do |i| indices.each do |i|
symlink = get_tagged_entry_path(i, key) symlink = get_tagged_entry_path(i, key)
::File.delete symlink
::File.delete symlink if ::File.exists? symlink
# FIXME: Remove directories if empty?
end end
end end
@ -114,4 +114,3 @@ class DODB::Tags(V) < DODB::Indexer(V)
"../../../data/#{key}.json" "../../../data/#{key}.json"
end end
end end