diff options
| author | Naios <naios-dev@live.de> | 2015-04-04 23:59:28 +0200 |
|---|---|---|
| committer | Naios <naios-dev@live.de> | 2015-04-05 00:23:12 +0200 |
| commit | de490674ff1205d908301b94f5644247562b43cb (patch) | |
| tree | a94da802bf54a449ac9e228290586bfaabb74b26 /src | |
| parent | 85d6ff9570869bce368e9bbcf881755c6c89cb55 (diff) | |
Core/DBUpdater: Exit clean if a query failed to apply.
* Fix some \W4 warnings about constructors.
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/shared/Updater/DBUpdater.cpp | 27 | ||||
| -rw-r--r-- | src/server/shared/Updater/UpdateFetcher.h | 6 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/server/shared/Updater/DBUpdater.cpp b/src/server/shared/Updater/DBUpdater.cpp index 5918fe06b55..e5c571e4517 100644 --- a/src/server/shared/Updater/DBUpdater.cpp +++ b/src/server/shared/Updater/DBUpdater.cpp @@ -239,11 +239,19 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool) [&](Path const& file) { DBUpdater<T>::ApplyFile(pool, file); }, [&](std::string const& query) -> QueryResult { return DBUpdater<T>::Retrieve(pool, query); }); - uint32 const count = updateFetcher.Update( - sConfigMgr->GetBoolDefault("Updates.Redundancy", true), - sConfigMgr->GetBoolDefault("Updates.AllowRehash", true), - sConfigMgr->GetBoolDefault("Updates.ArchivedRedundancy", false), - sConfigMgr->GetIntDefault("Updates.CleanDeadRefMaxCount", 3)); + uint32 count; + try + { + count = updateFetcher.Update( + sConfigMgr->GetBoolDefault("Updates.Redundancy", true), + sConfigMgr->GetBoolDefault("Updates.AllowRehash", true), + sConfigMgr->GetBoolDefault("Updates.ArchivedRedundancy", false), + sConfigMgr->GetIntDefault("Updates.CleanDeadRefMaxCount", 3)); + } + catch (UpdateException&) + { + return false; + } if (!count) TC_LOG_INFO("sql.updates", ">> %s database is up-to-date!", DBUpdater<T>::GetTableName().c_str()); @@ -298,7 +306,14 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool) // Update database TC_LOG_INFO("sql.updates", ">> Applying \'%s\'...", base.generic_string().c_str()); - ApplyFile(pool, base); + try + { + ApplyFile(pool, base); + } + catch (UpdateException&) + { + return false; + } TC_LOG_INFO("sql.updates", ">> Done!"); return true; diff --git a/src/server/shared/Updater/UpdateFetcher.h b/src/server/shared/Updater/UpdateFetcher.h index 094e353f274..95988224ee2 100644 --- a/src/server/shared/Updater/UpdateFetcher.h +++ b/src/server/shared/Updater/UpdateFetcher.h @@ -61,6 +61,9 @@ private: uint64 const timestamp; + AppliedFileEntry(std::string const& _name, std::string const& _hash, State const _state, uint64 const _timestamp) : + name(_name), hash(_hash), state(_state), timestamp(_timestamp) { } + static inline State StateConvert(std::string const& state) { return (state == "RELEASED") ? RELEASED : ARCHIVED; @@ -82,6 +85,9 @@ private: Path const path; State const state; + + DirectoryEntry(Path const& _path, State const _state) : + path(_path), state(_state) { } }; using LocaleFileEntry = std::pair<Path, State>; |
