[Box Backup-commit] COMMIT r1482 - box/chris/merge/bin/bbackupd

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sat, 24 Mar 2007 23:14:27 +0000


Author: chris
Date: 2007-03-24 23:14:27 +0000 (Sat, 24 Mar 2007)
New Revision: 1482

Modified:
   box/chris/merge/bin/bbackupd/BackupDaemon.cpp
Log:
Better handle a case where a force-sync command comes in immediately
after (or during) a sync, i.e. less than MinimumFileAge seconds after
the last one. In this case, just move back the syncPeriodStart by 1 second.
(refs #3, merges part if [1459])


Modified: box/chris/merge/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2007-03-24 23:12:20 UTC (rev 1481)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2007-03-24 23:14:27 UTC (rev 1482)
@@ -646,6 +646,18 @@
 			box_time_t syncPeriodEnd = currentSyncStartTime - 
 				minimumFileAge;
 
+			if(syncPeriodStart >= syncPeriodEnd &&
+				syncPeriodStart - syncPeriodEnd < minimumFileAge)
+			{
+				// This can happen if we receive a force-sync
+				// command less than minimumFileAge after
+				// the last sync. Deal with it by moving back
+				// syncPeriodStart, which should not do any
+				// damage.
+				syncPeriodStart = syncPeriodEnd -
+					SecondsToBoxTime(1);
+			}
+
 			if(syncPeriodStart >= syncPeriodEnd)
 			{
 				BOX_ERROR("Invalid (negative) sync period: "