summaryrefslogtreecommitdiff
path: root/bin/bbackupd
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-07-18 21:58:59 +0000
committerChris Wilson <chris+github@qwirx.com>2007-07-18 21:58:59 +0000
commit2cee87c2df1aa7809c07907cfc3a61f39796c2ad (patch)
tree7aecb9e3cc68c5936f2c2b37f9ab72400e82f005 /bin/bbackupd
parent35fce7de6b3ff302dab90f8013d9ebd434f90b03 (diff)
Hopefully fix a bug reported by Tobias Balle-Petersen, where unused
locations on the store would never be deleted because the timer would be reset on every backup pass (refs #3).
Diffstat (limited to 'bin/bbackupd')
-rw-r--r--bin/bbackupd/BackupDaemon.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index cfe2b7ab..d690e299 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -1812,10 +1812,27 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
// Any entries in the root directory which need deleting?
if(dir.GetNumberOfEntries() > 0)
{
+ box_time_t now = GetCurrentBoxTime();
+
+ // This should reset the timer if the list of unused
+ // locations changes, but it will not if the number of
+ // unused locations does not change, but the locations
+ // do change, e.g. one mysteriously appears and another
+ // mysteriously appears. (FIXME)
+ if (dir.GetNumberOfEntries() != mUnusedRootDirEntries.size() ||
+ mDeleteUnusedRootDirEntriesAfter == 0)
+ {
+ mDeleteUnusedRootDirEntriesAfter = now +
+ SecondsToBoxTime(
+ BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER);
+ }
+
+ int secs = BoxTimeToSeconds(mDeleteUnusedRootDirEntriesAfter
+ - now);
+
BOX_NOTICE(dir.GetNumberOfEntries() << " redundant locations "
"in root directory found, will delete from store "
- "after " << BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER
- << " seconds.");
+ "after " << secs << " seconds.");
// Store directories in list of things to delete
mUnusedRootDirEntries.clear();
@@ -1826,14 +1843,13 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
// Add name to list
BackupStoreFilenameClear clear(en->GetName());
const std::string &name(clear.GetClearFilename());
- mUnusedRootDirEntries.push_back(std::pair<int64_t,std::string>(en->GetObjectID(), name));
+ mUnusedRootDirEntries.push_back(
+ std::pair<int64_t,std::string>
+ (en->GetObjectID(), name));
// Log this
BOX_INFO("Unused location in root: " << name);
}
ASSERT(mUnusedRootDirEntries.size() > 0);
- // Time to delete them
- mDeleteUnusedRootDirEntriesAfter =
- GetCurrentBoxTime() + SecondsToBoxTime(BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER);
}
}
@@ -2256,16 +2272,27 @@ void BackupDaemon::NotifySysadmin(int Event)
// --------------------------------------------------------------------------
void BackupDaemon::DeleteUnusedRootDirEntries(BackupClientContext &rContext)
{
- if(mUnusedRootDirEntries.empty() || mDeleteUnusedRootDirEntriesAfter == 0)
+ if(mUnusedRootDirEntries.empty())
{
- // Nothing to do.
+ BOX_INFO("Not deleting unused entries - none in list");
return;
}
+ if(mDeleteUnusedRootDirEntriesAfter == 0)
+ {
+ BOX_INFO("Not deleting unused entries - "
+ "zero delete time (bad)");
+ return;
+ }
+
// Check time
- if(GetCurrentBoxTime() < mDeleteUnusedRootDirEntriesAfter)
+ box_time_t now = GetCurrentBoxTime();
+ if(now < mDeleteUnusedRootDirEntriesAfter)
{
- // Too early to delete files
+ int secs = BoxTimeToSeconds(mDeleteUnusedRootDirEntriesAfter
+ - now);
+ BOX_INFO("Not deleting unused entries - too early ("
+ << secs << " seconds remaining)");
return;
}