mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Improve Masterlist loading semantics.
Masterlist::Load() shouldn't also update the masterlist when there's a separate Masterlist::Update() function available, it's confusing.
This commit is contained in:
+1
-2
@@ -311,8 +311,7 @@ LOOT_API unsigned int loot_load_lists(loot_db db, const char * const masterlistP
|
||||
|
||||
try {
|
||||
if (boost::filesystem::exists(masterlistPath)) {
|
||||
// We don't want to update the masterlist too.
|
||||
temp.MetadataList::Load(masterlistPath);
|
||||
temp.Load(masterlistPath);
|
||||
}
|
||||
else {
|
||||
return c_error(loot_error_path_not_found, std::string("The given masterlist path does not exist: ") + masterlistPath);
|
||||
|
||||
@@ -35,22 +35,6 @@ namespace fs = boost::filesystem;
|
||||
namespace lc = boost::locale;
|
||||
|
||||
namespace loot {
|
||||
bool Masterlist::Load(Game& game, const unsigned int language) {
|
||||
try {
|
||||
return Update(game);
|
||||
}
|
||||
catch (error& e) {
|
||||
if (e.code() != error::ok) {
|
||||
// Error wasn't a parsing error. Need to try parsing masterlist if it exists.
|
||||
try {
|
||||
MetadataList::Load(game.MasterlistPath());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Masterlist::GetRevision(const boost::filesystem::path& path, bool shortID) {
|
||||
if (revision.empty() || (shortID && revision.length() == 40) || (!shortID && revision.length() < 40))
|
||||
GetGitInfo(path, shortID);
|
||||
@@ -393,7 +377,7 @@ namespace loot {
|
||||
//Now try parsing the masterlist.
|
||||
BOOST_LOG_TRIVIAL(debug) << "Testing masterlist parsing.";
|
||||
try {
|
||||
this->MetadataList::Load(path);
|
||||
this->Load(path);
|
||||
|
||||
for (auto &plugin : plugins) {
|
||||
plugin.ParseAllConditions();
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace loot {
|
||||
class Masterlist : public MetadataList {
|
||||
public:
|
||||
|
||||
bool Load(Game& game, const unsigned int language); //Handles update with load fallback.
|
||||
|
||||
bool Update(const Game& game);
|
||||
bool Update(const boost::filesystem::path& path,
|
||||
const std::string& repoURL,
|
||||
const std::string& repoBranch);
|
||||
@@ -47,7 +46,6 @@ namespace loot {
|
||||
std::string GetDate(const boost::filesystem::path& path);
|
||||
|
||||
private:
|
||||
bool Update(const Game& game);
|
||||
void GetGitInfo(const boost::filesystem::path& path, bool shortID);
|
||||
|
||||
std::string revision;
|
||||
|
||||
+10
-4
@@ -652,7 +652,7 @@ namespace loot {
|
||||
SendProgressUpdate(frame, loc::translate("Parsing masterlist..."));
|
||||
BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist.";
|
||||
try {
|
||||
_lootState.CurrentGame().masterlist.MetadataList::Load(_lootState.CurrentGame().MasterlistPath());
|
||||
_lootState.CurrentGame().masterlist.Load(_lootState.CurrentGame().MasterlistPath());
|
||||
}
|
||||
catch (exception &e) {
|
||||
_lootState.CurrentGame().masterlist.messages.push_back(Message(Message::error, (boost::format(loc::translate("An error occurred while parsing the masterlist: %1%")) % e.what()).str()));
|
||||
@@ -815,7 +815,7 @@ namespace loot {
|
||||
bool wasChanged = true;
|
||||
try {
|
||||
SendProgressUpdate(frame, loc::translate("Updating and parsing masterlist..."));
|
||||
wasChanged = _lootState.CurrentGame().masterlist.Load(_lootState.CurrentGame(), language);
|
||||
wasChanged = _lootState.CurrentGame().masterlist.Update(_lootState.CurrentGame());
|
||||
}
|
||||
catch (loot::error &e) {
|
||||
if (e.code() == loot::error::ok) {
|
||||
@@ -825,8 +825,14 @@ namespace loot {
|
||||
_lootState.CurrentGame().masterlist.messages.push_back(Message(Message::error, e.what()));
|
||||
wasChanged = true;
|
||||
}
|
||||
else
|
||||
throw;
|
||||
else {
|
||||
// Error wasn't a parsing error. Need to try parsing masterlist if it exists.
|
||||
try {
|
||||
_lootState.CurrentGame().masterlist.Load(_lootState.CurrentGame().MasterlistPath());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
// Now regenerate the JS-side masterlist data if the masterlist was changed.
|
||||
|
||||
Reference in New Issue
Block a user