From 580712acd11d5afdacd51c2e8d29313efc93d520 Mon Sep 17 00:00:00 2001 From: cooljqln Date: Fri, 24 Jan 2025 00:40:48 +0000 Subject: Resolve some issues with dangling index records (#193) - The tag parser's cache is now cleared between indexing runs, preventing stale data from being used - Multi-value tag fields (genres, all artists) are now properly ingested in the tag value cache - Cleaning up removed index records now properly handles the case where only a subset of the records for multi-value tags need to be deleted. - Synthesizing missing tag values is now done in the tag parser instead of TrackTags, which resolves some issues with multi-value tag callbacks from libtags not being handled properly These fixes seem to address all the issues with stale index records we were able to repro (including the issues in https://codeberg.org/cool-tech-zone/tangara-fw/issues/191), but if you've got any more cases with consistent repros then lmk! Co-authored-by: ailurux Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/193 --- src/tangara/database/index.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/tangara/database/index.cpp') diff --git a/src/tangara/database/index.cpp b/src/tangara/database/index.cpp index e60f56d5..7f594700 100644 --- a/src/tangara/database/index.cpp +++ b/src/tangara/database/index.cpp @@ -77,8 +77,8 @@ const IndexInfo kAudiobooks{ .components = {Tag::kAlbum, Tag::kAlbumOrder}, }; -static auto titleOrFilename(const TrackData& data, const TrackTags& tags) - -> std::pmr::string { +static auto titleOrFilename(const TrackData& data, + const TrackTags& tags) -> std::pmr::string { auto title = tags.title(); if (title) { return *title; @@ -147,8 +147,7 @@ auto Indexer::index() -> std::vector> { IndexKey::Header root_header{ .id = index_.id, - .depth = 0, - .components_hash = 0, + .components_hash = {}, }; handleLevel(root_header, index_.components); @@ -237,16 +236,10 @@ auto Index(locale::ICollator& collator, } auto ExpandHeader(const IndexKey::Header& header, - const std::optional& component) - -> IndexKey::Header { + const std::pmr::string& component) -> IndexKey::Header { IndexKey::Header ret{header}; - ret.depth++; - if (component) { - ret.components_hash = - komihash(component->data(), component->size(), ret.components_hash); - } else { - ret.components_hash = komihash(NULL, 0, ret.components_hash); - } + ret.components_hash.push_back( + komihash(component.data(), component.size(), 0)); return ret; } -- cgit v1.2.3