[Box Backup-commit] COMMIT r1981 - in box/chris/general: bin/bbackupd lib/backupclient

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sun, 9 Dec 2007 01:35:08 +0000 (UTC)


Author: chris
Date: 2007-12-09 01:35:08 +0000 (Sun, 09 Dec 2007)
New Revision: 1981

Modified:
   box/chris/general/bin/bbackupd/BackupDaemon.cpp
   box/chris/general/bin/bbackupd/BackupDaemon.h
   box/chris/general/lib/backupclient/BackupDaemonConfigVerify.cpp
   box/chris/general/lib/backupclient/BackupStoreConstants.h
Log:
Allow configuration of the time to delete redundant store locations.
(merges [1863])


Modified: box/chris/general/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/general/bin/bbackupd/BackupDaemon.cpp	2007-12-09 01:33:58 UTC (rev 1980)
+++ box/chris/general/bin/bbackupd/BackupDaemon.cpp	2007-12-09 01:35:08 UTC (rev 1981)
@@ -983,6 +983,9 @@
 					SecondsToBoxTime(
 						conf.GetKeyValueInt(
 							"MaxFileTimeInFuture"));
+				mDeleteRedundantLocationsAfter =
+					conf.GetKeyValueInt(
+						"DeleteRedundantLocationsAfter");
 
 				clientContext.SetMaximumDiffingTime(maximumDiffingTime);
 				clientContext.SetKeepAliveTime(keepAliveTime);
@@ -1766,7 +1769,7 @@
 	for(std::list<std::pair<std::string, Configuration> >::const_iterator i = rLocationsConf.mSubConfigurations.begin();
 		i != rLocationsConf.mSubConfigurations.end(); ++i)
 	{
-		BOX_TRACE("new location");
+		BOX_TRACE("new location: " << i->first);
 		// Create a record for it
 		std::auto_ptr<Location> apLoc(new Location);
 
@@ -1938,6 +1941,8 @@
 				<< apLoc->mName << "' path '"
 				<< apLoc->mPath << "': " << e.what() <<
 				": please check for previous errors");
+			delete ploc;
+			ploc = 0;
 			throw;
 		}
 		catch(...)
@@ -1953,6 +1958,23 @@
 	// 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(mDeleteRedundantLocationsAfter);
+		}
+
+		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 

Modified: box/chris/general/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/chris/general/bin/bbackupd/BackupDaemon.h	2007-12-09 01:33:58 UTC (rev 1980)
+++ box/chris/general/bin/bbackupd/BackupDaemon.h	2007-12-09 01:35:08 UTC (rev 1981)
@@ -166,6 +166,8 @@
 	std::vector<BackupClientInodeToIDMap *> mCurrentIDMaps;
 	std::vector<BackupClientInodeToIDMap *> mNewIDMaps;
 	
+	int mDeleteRedundantLocationsAfter;
+
 	// For the command socket
 	class CommandSocketInfo
 	{

Modified: box/chris/general/lib/backupclient/BackupDaemonConfigVerify.cpp
===================================================================
--- box/chris/general/lib/backupclient/BackupDaemonConfigVerify.cpp	2007-12-09 01:33:58 UTC (rev 1980)
+++ box/chris/general/lib/backupclient/BackupDaemonConfigVerify.cpp	2007-12-09 01:35:08 UTC (rev 1981)
@@ -77,6 +77,7 @@
 				// return "now" if it's allowed, or a number of seconds if it's not
 
 	{"MaximumDiffingTime", 0, ConfigTest_IsInt, 0},
+	{"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0},
 
 	{"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
 	{"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},

Modified: box/chris/general/lib/backupclient/BackupStoreConstants.h
===================================================================
--- box/chris/general/lib/backupclient/BackupStoreConstants.h	2007-12-09 01:33:58 UTC (rev 1980)
+++ box/chris/general/lib/backupclient/BackupStoreConstants.h	2007-12-09 01:35:08 UTC (rev 1981)
@@ -40,14 +40,5 @@
 // This is a multiple of the number of blocks in the diff from file.
 #define BACKUP_FILE_DIFF_MAX_BLOCK_FIND_MULTIPLE	4096
 
-// How many seconds to wait before deleting unused root directory entries?
-#ifndef NDEBUG
-	// Debug: 30 seconds (easier to test)
-	#define BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER		30
-#else
-	// Release: 2 days (plenty of time for sysadmins to notice, or change their mind)
-	#define BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER		172800
-#endif
-
 #endif // BACKUPSTORECONSTANTS__H