mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-13 20:52:15 +02:00
ncm: inline getlatestkey
This commit is contained in:
parent
a9953fc805
commit
4f4a54abda
@ -49,31 +49,6 @@ namespace ams::ncm {
|
|||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ContentMetaDatabaseImpl::GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const {
|
|
||||||
R_TRY(this->EnsureEnabled());
|
|
||||||
|
|
||||||
std::optional<ContentMetaKey> found_key = std::nullopt;
|
|
||||||
|
|
||||||
/* Find the last key with the desired program id. */
|
|
||||||
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
|
|
||||||
/* No further entries will match the program id, discontinue. */
|
|
||||||
if (entry->GetKey().id != id) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We are only interested in keys with the Full content install type. */
|
|
||||||
if (entry->GetKey().install_type == ContentInstallType::Full) {
|
|
||||||
found_key = entry->GetKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the key is absent. */
|
|
||||||
R_UNLESS(found_key, ncm::ResultContentMetaNotFound());
|
|
||||||
|
|
||||||
*out_key = *found_key;
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, sf::InBuffer value) {
|
Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, sf::InBuffer value) {
|
||||||
R_TRY(this->EnsureEnabled());
|
R_TRY(this->EnsureEnabled());
|
||||||
return this->kvs->Set(key, value.GetPointer(), value.GetSize());
|
return this->kvs->Set(key, value.GetPointer(), value.GetSize());
|
||||||
@ -173,7 +148,27 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
|
Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
|
||||||
R_TRY(this->EnsureEnabled());
|
R_TRY(this->EnsureEnabled());
|
||||||
return this->GetLatestKeyImpl(out_key.GetPointer(), id);
|
|
||||||
|
std::optional<ContentMetaKey> found_key = std::nullopt;
|
||||||
|
|
||||||
|
/* Find the last key with the desired program id. */
|
||||||
|
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
|
||||||
|
/* No further entries will match the program id, discontinue. */
|
||||||
|
if (entry->GetKey().id != id) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We are only interested in keys with the Full content install type. */
|
||||||
|
if (entry->GetKey().install_type == ContentInstallType::Full) {
|
||||||
|
found_key = entry->GetKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the key is absent. */
|
||||||
|
R_UNLESS(found_key, ncm::ResultContentMetaNotFound());
|
||||||
|
|
||||||
|
out_key.SetValue(*found_key);
|
||||||
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ContentMetaDatabaseImpl::ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType type) {
|
Result ContentMetaDatabaseImpl::ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType type) {
|
||||||
|
@ -26,7 +26,6 @@ namespace ams::ncm {
|
|||||||
private:
|
private:
|
||||||
/* Helpers. */
|
/* Helpers. */
|
||||||
Result GetContentIdImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional<u8> id_offset) const;
|
Result GetContentIdImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional<u8> id_offset) const;
|
||||||
Result GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const;
|
|
||||||
public:
|
public:
|
||||||
/* Actual commands. */
|
/* Actual commands. */
|
||||||
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override;
|
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override;
|
||||||
|
@ -18,29 +18,6 @@
|
|||||||
|
|
||||||
namespace ams::ncm {
|
namespace ams::ncm {
|
||||||
|
|
||||||
Result ContentMetaDatabaseImpl::GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const {
|
|
||||||
R_TRY(this->EnsureEnabled());
|
|
||||||
|
|
||||||
std::optional<ContentMetaKey> found_key = std::nullopt;
|
|
||||||
|
|
||||||
/* Find the last key with the desired program id. */
|
|
||||||
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
|
|
||||||
/* No further entries will match the program id, discontinue. */
|
|
||||||
if (entry->GetKey().id != id) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* On memory content database is interested in all keys. */
|
|
||||||
found_key = entry->GetKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the key is absent. */
|
|
||||||
R_UNLESS(found_key, ncm::ResultContentMetaNotFound());
|
|
||||||
|
|
||||||
*out_key = *found_key;
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result OnMemoryContentMetaDatabaseImpl::List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) {
|
Result OnMemoryContentMetaDatabaseImpl::List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) {
|
||||||
/* NOTE: This function is *almost* identical to the ContentMetaDatabaseImpl equivalent. */
|
/* NOTE: This function is *almost* identical to the ContentMetaDatabaseImpl equivalent. */
|
||||||
/* The only difference is that the min max comparison is exclusive for OnMemoryContentMetaDatabaseImpl, */
|
/* The only difference is that the min max comparison is exclusive for OnMemoryContentMetaDatabaseImpl, */
|
||||||
@ -89,7 +66,25 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
|
Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
|
||||||
R_TRY(this->EnsureEnabled());
|
R_TRY(this->EnsureEnabled());
|
||||||
return this->GetLatestKeyImpl(out_key.GetPointer(), id);
|
|
||||||
|
std::optional<ContentMetaKey> found_key = std::nullopt;
|
||||||
|
|
||||||
|
/* Find the last key with the desired program id. */
|
||||||
|
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
|
||||||
|
/* No further entries will match the program id, discontinue. */
|
||||||
|
if (entry->GetKey().id != id) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On memory content database is interested in all keys. */
|
||||||
|
found_key = entry->GetKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the key is absent. */
|
||||||
|
R_UNLESS(found_key, ncm::ResultContentMetaNotFound());
|
||||||
|
|
||||||
|
out_key.SetValue(*found_key);
|
||||||
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result OnMemoryContentMetaDatabaseImpl::LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
|
Result OnMemoryContentMetaDatabaseImpl::LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
|
||||||
|
@ -22,7 +22,6 @@ namespace ams::ncm {
|
|||||||
class OnMemoryContentMetaDatabaseImpl : public ContentMetaDatabaseImpl {
|
class OnMemoryContentMetaDatabaseImpl : public ContentMetaDatabaseImpl {
|
||||||
public:
|
public:
|
||||||
OnMemoryContentMetaDatabaseImpl(ams::kvdb::MemoryKeyValueStore<ContentMetaKey> *kvs) : ContentMetaDatabaseImpl(kvs) { /* ... */ }
|
OnMemoryContentMetaDatabaseImpl(ams::kvdb::MemoryKeyValueStore<ContentMetaKey> *kvs) : ContentMetaDatabaseImpl(kvs) { /* ... */ }
|
||||||
Result GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const;
|
|
||||||
public:
|
public:
|
||||||
/* Actual commands. */
|
/* Actual commands. */
|
||||||
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override;
|
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user