mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2025-02-15 03:19:11 +01:00
StorageAPI: Make sure we keep mHandle of rootItem when force-reloading storage
This commit is contained in:
parent
f859f13978
commit
1cef78d8bf
@ -11,3 +11,9 @@ void StorageItemRoot::wipe() {
|
|||||||
mSubCategories.clear();
|
mSubCategories.clear();
|
||||||
mItems.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 wipe();
|
||||||
|
|
||||||
|
void migrate(StorageItemRoot &&other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mPluginName;
|
std::string mPluginName;
|
||||||
};
|
};
|
||||||
|
@ -196,16 +196,16 @@ namespace StorageUtils {
|
|||||||
return err;
|
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()) {
|
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 {
|
} else {
|
||||||
storage = StorageUtils::Helper::deserializeFromJson(j["storageitems"], plugin_id);
|
newStorage = deserializeFromJson(j["storageitems"], plugin_id);
|
||||||
if (!storage) {
|
if (!newStorage) {
|
||||||
storage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
newStorage = make_unique_nothrow<StorageItemRoot>(plugin_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootItem = std::move(*storage);
|
rootItem.migrate(std::move(*newStorage));
|
||||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user