| 390 | } |
| 391 | |
| 392 | Result Installer::UpdateRecordAndContentMetas() { |
| 393 | const auto &main_program = this->inst_contents.front(); |
| 394 | const auto base_app_id = cnt::GetBaseApplicationId(main_program.meta_key.id, static_cast<NcmContentMetaType>(main_program.meta_key.type)); |
| 395 | |
| 396 | u8 *meta_data; |
| 397 | size_t meta_data_size; |
| 398 | this->packaged_cnt_meta.CreateContentMetaForInstall(this->meta_cnt_info, meta_data, meta_data_size, g_Settings.json_settings.installs.value().ignore_required_fw_version.value()); |
| 399 | GLEAF_RC_TRY(ncmContentMetaDatabaseSet(&this->cnt_meta_db, std::addressof(main_program.meta_key), meta_data, meta_data_size)); |
| 400 | GLEAF_RC_TRY(ncmContentMetaDatabaseCommit(&this->cnt_meta_db)); |
| 401 | delete[] meta_data; |
| 402 | |
| 403 | // Already installed something, need to refresh the application list for future uses |
| 404 | cnt::NotifyApplicationsChanged(); |
| 405 | g_MainApplication->GetApplicationListLayout()->NotifyApplicationsChanged(); |
| 406 | |
| 407 | s32 content_meta_count = 0; |
| 408 | GLEAF_RC_TRY_EXCEPT(nsCountApplicationContentMeta(base_app_id, &content_meta_count), rc::ns::ResultApplicationIdNotFound); |
| 409 | |
| 410 | std::vector<NsExtContentStorageMetaKey> content_storage_meta_keys; |
| 411 | if(content_meta_count > 0) { |
| 412 | auto cnt_storage_meta_key_buf = new NsExtContentStorageMetaKey[content_meta_count](); |
| 413 | ScopeGuard on_exit([&]() { |
| 414 | delete[] cnt_storage_meta_key_buf; |
| 415 | }); |
| 416 | |
| 417 | u32 real_count = 0; |
| 418 | GLEAF_RC_TRY(nsextListApplicationRecordContentMeta(0, base_app_id, cnt_storage_meta_key_buf, content_meta_count, &real_count)); |
| 419 | content_storage_meta_keys.reserve(real_count); |
| 420 | for(u32 i = 0; i < real_count; i++) { |
| 421 | content_storage_meta_keys.push_back(cnt_storage_meta_key_buf[i]); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | const NsExtContentStorageMetaKey cnt_storage_meta_key = { |
| 426 | .meta_key = main_program.meta_key, |
| 427 | .storage_id = this->storage_id, |
| 428 | }; |
| 429 | content_storage_meta_keys.push_back(cnt_storage_meta_key); |
| 430 | nsextDeleteApplicationRecord(base_app_id); |
| 431 | GLEAF_RC_TRY(nsextPushApplicationRecord(base_app_id, NsExtApplicationEvent_Present, content_storage_meta_keys.data(), content_storage_meta_keys.size())); |
| 432 | |
| 433 | GLEAF_RC_SUCCEED; |
| 434 | } |
| 435 | |
| 436 | Result Installer::WriteContents(OnStartWriteFunction on_start_write_fn, OnContentWriteFunction on_content_write_fn) { |
| 437 | auto nand_sys_explorer = fs::GetNANDSystemExplorer(); |
no test coverage detected