mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Make JSON reading safer
- Check that the file actually opened before reading it - If the JSON was discarded, then make just use an empty object
This commit is contained in:
@@ -50,19 +50,15 @@ public:
|
||||
std::vector<std::string> GetInstalled(const std::string &unistoreName, const std::string &entry) const;
|
||||
|
||||
void SetUpdated(const std::string &unistoreName, const std::string &entry, const std::string &updated) {
|
||||
if (this->metadataJson.is_discarded()) return;
|
||||
this->metadataJson[unistoreName][entry]["updated"] = updated;
|
||||
};
|
||||
|
||||
void SetMarks(const std::string &unistoreName, const std::string &entry, int marks) {
|
||||
if (this->metadataJson.is_discarded()) return;
|
||||
this->metadataJson[unistoreName][entry]["marks"] = marks;
|
||||
};
|
||||
|
||||
/* TODO: Handle this better. */
|
||||
void SetInstalled(const std::string &unistoreName, const std::string &entry, const std::string &name) {
|
||||
if (this->metadataJson.is_discarded()) return;
|
||||
|
||||
const std::vector<std::string> installs = this->GetInstalled(unistoreName, entry);
|
||||
bool write = true;
|
||||
|
||||
@@ -82,8 +78,6 @@ public:
|
||||
|
||||
/* Remove installed state from a download list entry. */
|
||||
void RemoveInstalled(const std::string &unistoreName, const std::string &entry, const std::string &name) {
|
||||
if (this->metadataJson.is_discarded()) return;
|
||||
|
||||
const std::vector<std::string> installs = this->GetInstalled(unistoreName, entry);
|
||||
int idx = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user