@@ -87,8 +87,7 @@ Result<> IndexManager::loadIndex(std::filesystem::path path) {
8787}
8888
8989Result<> IndexManager::loadIndex (matjson::Value&& jsonObj) {
90- GEODE_UNWRAP_INTO (IndexMetadata indexMeta,
91- matjson::Serialize<IndexMetadata>::fromJson (jsonObj));
90+ GEODE_UNWRAP_INTO (auto indexMeta, jsonObj.as <IndexMetadata>());
9291 std::unique_ptr<IndexMetadata> index =
9392 std::make_unique<IndexMetadata>(std::move (indexMeta));
9493
@@ -138,18 +137,15 @@ Result<> IndexManager::loadIndex(matjson::Value&& jsonObj) {
138137 /* }*/
139138
140139 for (const auto & [key, hostedNong] : jsonObj[" nongs" ][" hosted" ]) {
141- Result<IndexSongMetadata> r =
142- matjson::Serialize<IndexSongMetadata>::fromJson (hostedNong);
143- if (r.isErr ()) {
144- event::SongError (
145- false ,
146- fmt::format (" Failed to parse index song: {}" , r.unwrapErr ()))
140+ GEODE_UNWRAP_OR_ELSE (r, err, hostedNong.as <IndexSongMetadata>()) {
141+ event::SongError (false ,
142+ fmt::format (" Failed to parse index song: {}" , err))
147143 .post ();
148144 continue ;
149145 }
150146
151147 std::unique_ptr<IndexSongMetadata> song =
152- std::make_unique<IndexSongMetadata>(r. unwrap ( ));
148+ std::make_unique<IndexSongMetadata>(std::move (r ));
153149
154150 song->uniqueID = key;
155151 song->parentID = index.get ();
@@ -167,11 +163,10 @@ Result<> IndexManager::loadIndex(matjson::Value&& jsonObj) {
167163
168164 Nongs* nongs = opt.value ();
169165
170- if (geode::Result<> r = nongs->registerIndexSong (song.get ());
171- r.isErr ()) {
166+ if (GEODE_UNWRAP_IF_ERR (err, nongs->registerIndexSong (song.get ()))) {
172167 event::SongError (
173- false , fmt::format ( " Failed to register index song: {} " ,
174- r. unwrapErr () ))
168+ false ,
169+ fmt::format ( " Failed to register index song: {} " , err ))
175170 .post ();
176171 }
177172 }
@@ -194,7 +189,14 @@ Result<> IndexManager::fetchIndexes() {
194189
195190 for (const IndexSource& index : indexes) {
196191 if (!index.m_enabled || index.m_url .size () < 3 ) {
197- log::info (" Skipping index {}, as it is disabled" , index.m_url );
192+ if (!index.m_userAdded ) {
193+ log::warn (
194+ " Skipping default index {} provided by Jukebox, as it is "
195+ " disabled" ,
196+ index.m_url );
197+ } else {
198+ log::info (" Skipping index {}, as it is disabled" , index.m_url );
199+ }
198200 continue ;
199201 }
200202
@@ -256,7 +258,6 @@ void IndexManager::onIndexFetched(const std::string& url,
256258
257259 const std::filesystem::path filepath =
258260 this ->baseIndexesPath () / fmt::format (" {0:x}.json" , hashValue);
259- log::info (" {}" , filepath);
260261
261262 log::info (" Fetched index: {}" , url);
262263
@@ -266,11 +267,11 @@ void IndexManager::onIndexFetched(const std::string& url,
266267 out.write (str.data (), str.length ());
267268 log::info (" Cached index: {}" , url);
268269 } else {
269- log::info (" Failed to cache index: {}" , url);
270+ log::error (" Failed to cache index: {}" , url);
270271 }
271272
272273 this ->loadIndex (std::move (json)).inspectErr ([url](const std::string& err) {
273- log::info (" Failed to load index {}: {}" , url, err);
274+ log::error (" Failed to load index {}: {}" , url, err);
274275 });
275276}
276277
@@ -366,8 +367,9 @@ Result<> IndexManager::downloadSong(int gdSongID, const std::string& uniqueID) {
366367 // If not uniqueID not found in local songs, search in indexes
367368 if (!found) {
368369 if (!m_nongsForId.contains (gdSongID)) {
369- return Err (" Can't download nong for id {}. No local or index songs found." ,
370- gdSongID);
370+ return Err (
371+ " Can't download nong for id {}. No local or index songs found." ,
372+ gdSongID);
371373 }
372374
373375 std::vector<IndexSongMetadata*> songs = m_nongsForId[gdSongID];
@@ -546,8 +548,7 @@ void IndexManager::onDownloadFinish(
546548ListenerResult IndexManager::onDownloadStart (event::StartDownload* e) {
547549 Result<> res = this ->downloadSong (e->gdSongID (), e->uniqueID ());
548550 if (res.isErr ()) {
549- event::SongDownloadFailed (e->gdSongID (), e->uniqueID (),
550- res.unwrapErr ())
551+ event::SongDownloadFailed (e->gdSongID (), e->uniqueID (), res.unwrapErr ())
551552 .post ();
552553 }
553554 return ListenerResult::Propagate;
0 commit comments