diff --git a/src/backend/network.cpp b/src/backend/network.cpp index 263243ec..a6707fdc 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -45,6 +45,10 @@ namespace loot { public: git_handler() : repo(nullptr), remote(nullptr), cfg(nullptr), obj(nullptr), commit(nullptr), ref(nullptr), sig(nullptr), blob(nullptr) {} + ~git_handler() { + free(); + } + void free() { git_commit_free(commit); git_object_free(obj); @@ -182,7 +186,7 @@ namespace loot { git_handler git; BOOST_LOG_TRIVIAL(debug) << "Checking for a Git repository."; - git.ui_message = "An error occurred while trying to access the local masterlist repository. If this error happens again, try deleting the \".git\" folder in \"%LOCALAPPDATA%\\LOOT\\" + game.FolderName() + "\"."; + git.ui_message = "An error occurred while trying to access the local masterlist repository."; //Checking for a ".git" folder. if (fs::exists(game.MasterlistPath().parent_path() / ".git")) { @@ -266,10 +270,6 @@ namespace loot { 7. Perform the checkout of HEAD. */ - //Apparently I'm using libgit2's head, not v0.20.0, so I don't need this... - //LOG_INFO("Creating a Git signature."); - //git.call(git_signature_default(&git.sig, git.repo)); - bool parsingFailed = false; unsigned int rollbacks = 0; string revision, date; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index d9a0d40b..0ef30437 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -111,9 +111,24 @@ struct masterlist_updater_parser { if (_doUpdate) { BOOST_LOG_TRIVIAL(debug) << "Updating masterlist"; try { - pair ret = UpdateMasterlist(_game, _errors, _plugins, _messages); - _revision = ret.first; - _date = ret.second; + try { + pair ret = UpdateMasterlist(_game, _errors, _plugins, _messages); + _revision = ret.first; + _date = ret.second; + } + catch (loot::error &e) { + BOOST_LOG_TRIVIAL(error) << "Masterlist update failed. Details: " << e.what(); + if (e.code() == loot::error::git_error) { + BOOST_LOG_TRIVIAL(info) << "Masterlist update failure was due to Git error, deleting repository and retrying..."; + //Delete .git folder and try again. + fs::remove_all(_game.MasterlistPath().parent_path() / ".git"); + pair ret = UpdateMasterlist(_game, _errors, _plugins, _messages); + _revision = ret.first; + _date = ret.second; + } + else + throw e; + } } catch (std::exception& e) { _plugins.clear(); _messages.clear();