Report an error on update installation if the update script cannot be read.

This commit is contained in:
Robert Knight 2011-08-24 12:59:51 +01:00
parent 82de2a91f8
commit bae300a6a7
4 changed files with 28 additions and 0 deletions

View file

@ -55,8 +55,27 @@ std::list<std::string> UpdateInstaller::updaterArgs() const
return args; return args;
} }
void UpdateInstaller::reportError(const std::string& error)
{
if (m_observer)
{
m_observer->updateError(error);
}
}
void UpdateInstaller::run() throw () void UpdateInstaller::run() throw ()
{ {
if (!m_script || !m_script->isValid())
{
reportError("Unable to read update script");
return;
}
if (m_installDir.empty())
{
reportError("No installation directory specified");
return;
}
std::string updaterPath; std::string updaterPath;
try try
{ {

View file

@ -43,6 +43,7 @@ class UpdateInstaller
void uninstallFiles(); void uninstallFiles();
void installFile(const UpdateScriptFile& file); void installFile(const UpdateScriptFile& file);
void backupFile(const std::string& path); void backupFile(const std::string& path);
void reportError(const std::string& error);
std::list<std::string> updaterArgs() const; std::list<std::string> updaterArgs() const;

View file

@ -11,6 +11,8 @@ UpdateScript::UpdateScript()
void UpdateScript::parse(const std::string& path) void UpdateScript::parse(const std::string& path)
{ {
m_path.clear();
TiXmlDocument document(path); TiXmlDocument document(path);
if (document.LoadFile()) if (document.LoadFile())
{ {
@ -38,6 +40,11 @@ void UpdateScript::parse(const std::string& path)
} }
} }
bool UpdateScript::isValid() const
{
return !m_path.empty();
}
void UpdateScript::parseUpdate(const TiXmlElement* updateNode) void UpdateScript::parseUpdate(const TiXmlElement* updateNode)
{ {
const TiXmlElement* depsNode = updateNode->FirstChildElement("dependencies"); const TiXmlElement* depsNode = updateNode->FirstChildElement("dependencies");

View file

@ -57,6 +57,7 @@ class UpdateScript
void parse(const std::string& path); void parse(const std::string& path);
bool isValid() const;
const std::string path() const; const std::string path() const;
const std::vector<std::string>& dependencies() const; const std::vector<std::string>& dependencies() const;
const std::vector<UpdateScriptPackage>& packages() const; const std::vector<UpdateScriptPackage>& packages() const;