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