aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Updater/UpdateFetcher.cpp
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2015-03-24 12:31:52 +0100
committerNaios <naios-dev@live.de>2015-03-24 12:31:52 +0100
commit966282fbed24a0d0cf8cb3e05b1849c3e6a0d1d6 (patch)
treecad979bdbeb4e96335259dda19528ebcc09ac761 /src/server/shared/Updater/UpdateFetcher.cpp
parentbf4e71a008d253dc3c3a531e9950d5a415bc60e0 (diff)
Core/DBUpdater: Add the possibility to limit the remove of orphaned entries.
* This will save you from loosing your update history if you use a repository in bad state (revision or branch) by mistake. * Also turned 1 error message into a warning
Diffstat (limited to 'src/server/shared/Updater/UpdateFetcher.cpp')
-rw-r--r--src/server/shared/Updater/UpdateFetcher.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/server/shared/Updater/UpdateFetcher.cpp b/src/server/shared/Updater/UpdateFetcher.cpp
index 63e820c3de5..3958815d5d6 100644
--- a/src/server/shared/Updater/UpdateFetcher.cpp
+++ b/src/server/shared/Updater/UpdateFetcher.cpp
@@ -101,7 +101,7 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
if (!is_directory(p))
{
- TC_LOG_ERROR("sql.updates", "DBUpdater: Given update include directory \"%s\" isn't existing, skipped!", p.generic_string().c_str());
+ TC_LOG_WARN("sql.updates", "DBUpdater: Given update include directory \"%s\" isn't existing, skipped!", p.generic_string().c_str());
continue;
}
@@ -154,7 +154,7 @@ UpdateFetcher::SQLUpdate UpdateFetcher::ReadSQLUpdate(boost::filesystem::path co
return update;
}
-uint32 UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash, bool const archivedRedundancy, bool const cleanDeadReferences) const
+uint32 UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash, bool const archivedRedundancy, int32 const cleanDeadReferencesMaxCount) const
{
LocaleFileStorage const available = GetFileList();
AppliedFileStorage applied = ReceiveAppliedFiles();
@@ -291,14 +291,28 @@ uint32 UpdateFetcher::Update(bool const redundancyChecks, bool const allowRehash
++importedUpdates;
}
- for (auto const& entry : applied)
+ // Cleanup up orphaned entries if enabled
+ if (!applied.empty())
{
- TC_LOG_WARN("sql.updates", ">> File \'%s\' was applied to the database but is missing in" \
- " your update directory now!%s", entry.first.c_str(), cleanDeadReferences ? " Deleting orphaned entry..." : "");
- }
+ bool const doCleanup = (cleanDeadReferencesMaxCount == -1) || (applied.size() <= cleanDeadReferencesMaxCount);
+
+ for (auto const& entry : applied)
+ {
+ TC_LOG_WARN("sql.updates", ">> File \'%s\' was applied to the database but is missing in" \
+ " your update directory now!", entry.first.c_str());
+
+ if (doCleanup)
+ TC_LOG_INFO("sql.updates", "Deleting orphaned entry \'%s\'...", entry.first.c_str());
+ }
- if (cleanDeadReferences)
- CleanUp(applied);
+ if (doCleanup)
+ CleanUp(applied);
+ else
+ {
+ TC_LOG_ERROR("sql.updates", "Cleanup is disabled! There are %u dirty files that were applied to your database " \
+ "but are now missing in your source directory!", applied.size());
+ }
+ }
return importedUpdates;
}