mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2025-02-08 16:43:22 +01:00
StorageAPI: Make sure we keep mHandle of rootItem when force-reloading storage
This commit is contained in:
parent
f859f13978
commit
1cef78d8bf
@ -10,4 +10,10 @@ StorageItemRoot::StorageItemRoot(const std::string_view plugin_name) : StorageSu
|
||||
void StorageItemRoot::wipe() {
|
||||
mSubCategories.clear();
|
||||
mItems.clear();
|
||||
}
|
||||
|
||||
void StorageItemRoot::migrate(StorageItemRoot &&other) {
|
||||
mPluginName = std::move(other.mPluginName);
|
||||
mSubCategories = std::move(other.mSubCategories);
|
||||
mItems = std::move(other.mItems);
|
||||
}
|
@ -12,6 +12,8 @@ public:
|
||||
|
||||
void wipe();
|
||||
|
||||
void migrate(StorageItemRoot &&other);
|
||||
|
||||
private:
|
||||
std::string mPluginName;
|
||||
};
|
||||
|
@ -196,16 +196,16 @@ namespace StorageUtils {
|
||||
return err;
|
||||
}
|
||||
|
||||
std::unique_ptr<StorageItemRoot> storage;
|
||||
std::unique_ptr<StorageItemRoot> newStorage;
|
||||
if (j.empty() || !j.is_object() || !j.contains("storageitems") || j["storageitems"].empty() || !j["storageitems"].is_object()) {
|
||||
storage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
||||
newStorage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
||||
} else {
|
||||
storage = StorageUtils::Helper::deserializeFromJson(j["storageitems"], plugin_id);
|
||||
if (!storage) {
|
||||
storage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
||||
newStorage = deserializeFromJson(j["storageitems"], plugin_id);
|
||||
if (!newStorage) {
|
||||
newStorage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
||||
}
|
||||
}
|
||||
rootItem = std::move(*storage);
|
||||
rootItem.migrate(std::move(*newStorage));
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user