diff options
author | Naios <naios-dev@live.de> | 2015-06-20 14:33:31 +0200 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2015-06-20 14:33:31 +0200 |
commit | a5b3862bc1b066a9614369bda3adef485a57eff8 (patch) | |
tree | f85ceb5ce0c940655c10a6b55083864d24aa9d7b /src/server/shared/Updater/UpdateFetcher.cpp | |
parent | d04c9d55ac7441d39566f5bb3444aa0a08ac5318 (diff) |
Core/Updater: Add some info about the count of applied updates.
* some minor improvements
* add a log message when database updates are disabled.
Diffstat (limited to 'src/server/shared/Updater/UpdateFetcher.cpp')
-rw-r--r-- | src/server/shared/Updater/UpdateFetcher.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/server/shared/Updater/UpdateFetcher.cpp b/src/server/shared/Updater/UpdateFetcher.cpp index a4bdd193743..ec023928b99 100644 --- a/src/server/shared/Updater/UpdateFetcher.cpp +++ b/src/server/shared/Updater/UpdateFetcher.cpp @@ -154,17 +154,27 @@ UpdateFetcher::SQLUpdate UpdateFetcher::ReadSQLUpdate(boost::filesystem::path co return update; } -uint32 UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash, bool const archivedRedundancy, int32 const cleanDeadReferencesMaxCount) const +UpdateResult UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash, bool const archivedRedundancy, int32 const cleanDeadReferencesMaxCount) const { LocaleFileStorage const available = GetFileList(); AppliedFileStorage applied = ReceiveAppliedFiles(); + size_t countRecentUpdates = 0; + size_t countArchivedUpdates = 0; + + // Count updates + for (auto const& entry : applied) + if (entry.second.state == RELEASED) + ++countRecentUpdates; + else + ++countArchivedUpdates; + // Fill hash to name cache HashToFileNameStorage hashToName; for (auto entry : applied) hashToName.insert(std::make_pair(entry.second.hash, entry.first)); - uint32 importedUpdates = 0; + size_t importedUpdates = 0; for (auto const& availableQuery : available) { @@ -314,7 +324,7 @@ uint32 UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash } } - return importedUpdates; + return UpdateResult(importedUpdates, countRecentUpdates, countArchivedUpdates); } std::string UpdateFetcher::CalculateHash(SQLUpdate const& query) const @@ -329,7 +339,6 @@ std::string UpdateFetcher::CalculateHash(SQLUpdate const& query) const uint32 UpdateFetcher::Apply(Path const& path) const { using Time = std::chrono::high_resolution_clock; - using ms = std::chrono::milliseconds; // Benchmark query speed auto const begin = Time::now(); @@ -338,7 +347,7 @@ uint32 UpdateFetcher::Apply(Path const& path) const _applyFile(path); // Return time the query took to apply - return std::chrono::duration_cast<ms>(Time::now() - begin).count(); + return std::chrono::duration_cast<std::chrono::milliseconds>(Time::now() - begin).count(); } void UpdateFetcher::UpdateEntry(AppliedFileEntry const& entry, uint32 const speed) const |