From bcfe5d44d61ec752cc47d5d76540ab0337a4b1c6 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 26 Apr 2024 23:26:56 +0200 Subject: [PATCH] Tags should now be working as expected. --- src/dodb.cr | 6 +++--- src/dodb/partition.cr | 1 + src/dodb/tags.cr | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dodb.cr b/src/dodb.cr index 0e22ad6..e73e79c 100644 --- a/src/dodb.cr +++ b/src/dodb.cr @@ -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) diff --git a/src/dodb/partition.cr b/src/dodb/partition.cr index d0d4954..84960f3 100644 --- a/src/dodb/partition.cr +++ b/src/dodb/partition.cr @@ -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) diff --git a/src/dodb/tags.cr b/src/dodb/tags.cr index 1e269fc..e228089 100644 --- a/src/dodb/tags.cr +++ b/src/dodb/tags.cr @@ -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 -