summaryrefslogtreecommitdiff
path: root/src/database/index.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/index.cpp')
-rw-r--r--src/database/index.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/database/index.cpp b/src/database/index.cpp
index a828578d..84d00bcd 100644
--- a/src/database/index.cpp
+++ b/src/database/index.cpp
@@ -52,15 +52,20 @@ auto Index(const IndexInfo& info, const Track& t, leveldb::WriteBatch* batch)
key.item = {};
}
- // If this is the last component, then we should also fill in the track id.
+ // If this is the last component, then we should also fill in the track id
+ // and title.
+ std::optional<std::string> title;
if (i == info.components.size() - 1) {
key.track = t.data().id();
+ if (info.components.at(i) != Tag::kTitle) {
+ title = t.TitleOrFilename();
+ }
} else {
key.track = {};
}
auto encoded = EncodeIndexKey(key);
- batch->Put(encoded.slice, leveldb::Slice{});
+ batch->Put(encoded.slice, title.value_or(""));
// If there are more components after this, then we need to finish by
// narrowing the header with the current title.