[Box Backup-commit] COMMIT r3352 - in box/trunk: bin/bbackupd lib/server test/bbackupd

subversion at boxbackup.org subversion at boxbackup.org
Fri Aug 15 23:47:14 BST 2014


Author: chris
Date: 2014-08-15 23:47:14 +0100 (Fri, 15 Aug 2014)
New Revision: 3352

Modified:
   box/trunk/bin/bbackupd/BackupClientContext.cpp
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/trunk/bin/bbackupd/BackupDaemon.cpp
   box/trunk/bin/bbackupd/BackupDaemon.h
   box/trunk/bin/bbackupd/BackupDaemonInterface.h
   box/trunk/lib/server/Message.h
   box/trunk/test/bbackupd/testbbackupd.cpp
Log:
Whitespace, wrapping, comments and dead code cleanups.

Conflicts:

	bin/bbackupd/BackupDaemon.cpp
	bin/bbackupd/BackupDaemon.h
	test/bbackupd/testbbackupd.cpp

Modified: box/trunk/bin/bbackupd/BackupClientContext.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientContext.cpp	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/bin/bbackupd/BackupClientContext.cpp	2014-08-15 22:47:14 UTC (rev 3352)
@@ -126,8 +126,8 @@
 		mapConnection.reset();
 
 		// Log intention
-		BOX_INFO("Opening connection to server '" <<
-			mHostname << "'...");
+		BOX_INFO("Opening connection to server '" << mHostname <<
+			"'...");
 
 		// Connect!
 		((SocketStreamTLS *)(apSocket.get()))->Open(mrTLSContext,

Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2014-08-15 22:47:14 UTC (rev 3352)
@@ -1368,7 +1368,7 @@
 			// Note: if we have exceeded our storage limit, then
 			// we should not upload any more data, nor create any
 			// DirectoryRecord representing data that would have
-			// been uploaded. This step will be repeated when 
+			// been uploaded. This step will be repeated when
 			// there is some space available.
 			bool doCreateDirectoryRecord = true;
 			
@@ -1388,13 +1388,13 @@
 			else
 			{
 				// Yes, creation required!
-				// It is known that the it doesn't exist:
+				// It is known that it doesn't exist:
 				//
 				// if en == 0 and pDirOnStore == 0, then the
 				//   directory has had an initial sync, and
 				//   hasn't been modified (Really? then why
 				//   are we here? TODO FIXME)
-				//   so it has definately been created already
+				//   so it has definitely been created already
 				//   (so why create it again?)
 				//
 				// if en == 0 but pDirOnStore != 0, well... obviously it doesn't exist.
@@ -1515,7 +1515,7 @@
 			{
 				// New an object for this
 				psubDirRecord = new BackupClientDirectoryRecord(subDirObjectID, *d);
-				
+
 				// Store in list
 				try
 				{
@@ -1547,7 +1547,7 @@
 		if(rEntriesLeftOver[l] != 0)
 		{
 			BackupStoreDirectory::Entry *en = rEntriesLeftOver[l];
-		
+
 			// These entries can't be deleted immediately, as it would prevent
 			// renaming and moving of objects working properly. So we add them
 			// to a list, which is actually deleted at the very end of the session.
@@ -1574,7 +1574,7 @@
 				filenameClear);
 			std::string nonVssLocalName = ConvertVssPathToRealPath(localName,
 				rBackupLocation);
-			
+
 			// Delete this entry -- file or directory?
 			if((en->GetFlags() & BackupStoreDirectory::Entry::Flags_File) != 0)
 			{
@@ -1588,7 +1588,7 @@
 				rdel.AddDirectoryDelete(en->GetObjectID(),
 					localName);
 				
-				// If there's a directory record for it in 
+				// If there's a directory record for it in
 				// the sub directory map, delete it now
 				BackupStoreFilenameClear dirname(en->GetName());
 				std::map<std::string, BackupClientDirectoryRecord *>::iterator
@@ -1602,7 +1602,7 @@
 
 					BOX_TRACE("Deleted directory record for " << 
 						nonVssLocalName);
-				}				
+				}
 			}
 		}
 	}
@@ -1778,7 +1778,7 @@
 
 		rContext.SetNiceMode(false);
 
-		// Get object ID from the result		
+		// Get object ID from the result
 		objID = stored->GetObjectID();
 		uploadedSize = apStreamToUpload->GetTotalBytesSent();
 	}

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2014-08-15 22:47:14 UTC (rev 3352)
@@ -858,13 +858,13 @@
 	{
 		extendedLogFile = conf.GetKeyValue("ExtendedLogFile");
 	}
-	
+
 	if (conf.KeyExists("LogAllFileAccess"))
 	{
 		mLogAllFileAccess = conf.GetKeyValueBool("LogAllFileAccess");
 	}
-	
-	// Then create a client context object (don't 
+
+	// Then create a client context object (don't
 	// just connect, as this may be unnecessary)
 	BackupClientContext clientContext
 	(
@@ -872,7 +872,7 @@
 		mTlsContext, 
 		conf.GetKeyValue("StoreHostname"),
 		conf.GetKeyValueInt("StorePort"),
-		conf.GetKeyValueUint32("AccountNumber"), 
+		conf.GetKeyValueUint32("AccountNumber"),
 		conf.GetKeyValueBool("ExtendedLogging"),
 		conf.KeyExists("ExtendedLogFile"),
 		extendedLogFile,
@@ -879,7 +879,7 @@
 		*mpProgressNotifier,
 		conf.GetKeyValueBool("TcpNice")
 	);
-		
+
 	// The minimum age a file needs to be before it will be
 	// considered for uploading
 	box_time_t minimumFileAge = SecondsToBoxTime(
@@ -2414,7 +2414,7 @@
 
 			// Does this exist on the server?
 			// Remove from dir object early, so that if we fail
-			// to stat the local directory, we still don't 
+			// to stat the local directory, we still don't
 			// consider to remote one for deletion.
 			BackupStoreDirectory::Iterator iter(dir);
 			BackupStoreFilenameClear dirname(pLoc->mName);	// generate the filename

Modified: box/trunk/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.h	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/bin/bbackupd/BackupDaemon.h	2014-08-15 22:47:14 UTC (rev 3352)
@@ -196,10 +196,10 @@
 #endif
 		IOStreamGetLine *mpGetLine;
 	};
-	
+
 	// Using a socket?
 	std::auto_ptr<CommandSocketInfo> mapCommandSocketInfo;
-	
+
 	// Stop notifications being repeated.
 	SysadminNotifier::EventCode mLastNotifiedEvent;
 
@@ -220,7 +220,7 @@
 
 public:
 	int GetMaxBandwidthFromSyncAllowScript() { return mMaxBandwidthFromSyncAllowScript; }
- 	bool StopRun() { return this->Daemon::StopRun(); }
+	bool StopRun() { return this->Daemon::StopRun(); }
 	bool StorageLimitExceeded() { return mStorageLimitExceeded; }
  
 private:
@@ -249,9 +249,9 @@
 public:
 	virtual void NotifyIDMapsSetup(BackupClientContext& rContext) { }
 
- 	virtual void NotifyScanDirectory(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath) 
+	virtual void NotifyScanDirectory(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath) 
 	{
 		if (mLogAllFileAccess)
 		{
@@ -264,30 +264,30 @@
 				CancelledByBackgroundTask);
 		}
 	}
- 	virtual void NotifyDirStatFailed(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath, 
- 		const std::string& rErrorMsg)
- 	{
+	virtual void NotifyDirStatFailed(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath, 
+		const std::string& rErrorMsg)
+	{
 		BOX_WARNING("Failed to access directory: " << rLocalPath
 			<< ": " << rErrorMsg);
- 	}
- 	virtual void NotifyFileStatFailed(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		const std::string& rErrorMsg)
- 	{
+	}
+	virtual void NotifyFileStatFailed(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		const std::string& rErrorMsg)
+	{
 		BOX_WARNING("Failed to access file: " << rLocalPath
 			<< ": " << rErrorMsg);
- 	}
- 	virtual void NotifyDirListFailed(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		const std::string& rErrorMsg)
- 	{
+	}
+	virtual void NotifyDirListFailed(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		const std::string& rErrorMsg)
+	{
 		BOX_WARNING("Failed to list directory: " << rLocalPath
 			<< ": " << rErrorMsg);
- 	}
+	}
 	virtual void NotifyMountPointSkipped(
 		const BackupClientDirectoryRecord* pDirRecord,
 		const std::string& rLocalPath)
@@ -309,7 +309,7 @@
 		if (mLogAllFileAccess)
 		{
 			BOX_INFO("Skipping excluded file: " << rLocalPath);
-		} 
+		}
 	}
 	virtual void NotifyDirExcluded(
 		const BackupClientDirectoryRecord* pDirRecord,
@@ -318,7 +318,7 @@
 		if (mLogAllFileAccess)
 		{
 			BOX_INFO("Skipping excluded directory: " << rLocalPath);
-		} 
+		}
 	}
 	virtual void NotifyUnsupportedFileType(
 		const BackupClientDirectoryRecord* pDirRecord,
@@ -326,43 +326,43 @@
 	{
 		BOX_WARNING("Ignoring file of unknown type: " << rLocalPath);
 	}
- 	virtual void NotifyFileReadFailed(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		const std::string& rErrorMsg)
- 	{
+	virtual void NotifyFileReadFailed(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		const std::string& rErrorMsg)
+	{
 		BOX_WARNING("Error reading file: " << rLocalPath
 			<< ": " << rErrorMsg);
- 	}
- 	virtual void NotifyFileModifiedInFuture(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath)
- 	{
+	}
+	virtual void NotifyFileModifiedInFuture(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath)
+	{
 		BOX_WARNING("Some files have modification times excessively "
 			"in the future. Check clock synchronisation. "
 			"Example file (only one shown): " << rLocalPath);
- 	}
- 	virtual void NotifyFileSkippedServerFull(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath) 
+	}
+	virtual void NotifyFileSkippedServerFull(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath) 
 	{
 		BOX_WARNING("Skipped file: server is full: " << rLocalPath);
 	}
- 	virtual void NotifyFileUploadException(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		const BoxException& rException)
- 	{
+	virtual void NotifyFileUploadException(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		const BoxException& rException)
+	{
 		if (rException.GetType() == CommonException::ExceptionType &&
 			rException.GetSubType() == CommonException::AccessDenied)
 		{
-			BOX_ERROR("Failed to upload file: " << rLocalPath 
+			BOX_ERROR("Failed to upload file: " << rLocalPath
 				<< ": Access denied");
 		}
 		else
 		{
-			BOX_ERROR("Failed to upload file: " << rLocalPath 
-				<< ": caught exception: " << rException.what() 
+			BOX_ERROR("Failed to upload file: " << rLocalPath
+				<< ": caught exception: " << rException.what()
 				<< " (" << rException.GetType()
 				<< "/"  << rException.GetSubType() << ")");
 		}
@@ -428,41 +428,41 @@
 			}
 		}
 
-		BOX_ERROR("Failed to upload file: " << rLocalPath 
+		BOX_ERROR("Failed to upload file: " << rLocalPath
 			<< ": server error: " << msgs.str());
- 	}
- 	virtual void NotifyFileUploading(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath) 
-	{ 
+	}
+	virtual void NotifyFileUploading(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath)
+	{
 		if (mLogAllFileAccess)
 		{
 			BOX_NOTICE("Uploading complete file: " << rLocalPath);
-		} 
+		}
 	}
- 	virtual void NotifyFileUploadingPatch(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath) 
+	virtual void NotifyFileUploadingPatch(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath)
 	{
 		if (mLogAllFileAccess)
 		{
 			BOX_NOTICE("Uploading patch to file: " << rLocalPath);
-		} 
+		}
 	}
- 	virtual void NotifyFileUploadingAttributes(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath) 
+	virtual void NotifyFileUploadingAttributes(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath)
 	{
 		if (mLogAllFileAccess)
 		{
-			BOX_NOTICE("Uploading new file attributes: " << 
+			BOX_NOTICE("Uploading new file attributes: " <<
 				rLocalPath);
-		} 
+		}
 	}
- 	virtual void NotifyFileUploaded(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		int64_t FileSize, int64_t UploadedSize) 
+	virtual void NotifyFileUploaded(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		int64_t FileSize, int64_t UploadedSize)
 	{
 		if (mLogAllFileAccess)
 		{
@@ -472,10 +472,10 @@
 		}
 		mNumFilesUploaded++;
 	}
- 	virtual void NotifyFileSynchronised(
- 		const BackupClientDirectoryRecord* pDirRecord,
- 		const std::string& rLocalPath,
- 		int64_t FileSize) 
+	virtual void NotifyFileSynchronised(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		int64_t FileSize) 
 	{
 		if (mLogAllFileAccess)
 		{
@@ -489,7 +489,7 @@
 	{
 		if (mLogAllFileAccess)
 		{
-			BOX_NOTICE("Created directory: " << rRemotePath << 
+			BOX_NOTICE("Created directory: " << rRemotePath <<
 				" (ID " << BOX_FORMAT_OBJECTID(ObjectID) <<
 				")");
 		}

Modified: box/trunk/bin/bbackupd/BackupDaemonInterface.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemonInterface.h	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/bin/bbackupd/BackupDaemonInterface.h	2014-08-15 22:47:14 UTC (rev 3352)
@@ -11,14 +11,8 @@
 #define BACKUPDAEMONINTERFACE__H
 
 #include <string>
-// #include <map>
 
-// #include "BackupClientFileAttributes.h"
-// #include "BackupStoreDirectory.h"
 #include "BoxTime.h"
-// #include "MD5Digest.h"
-// #include "ReadLoggingStream.h"
-// #include "RunStatusProvider.h"
 
 class Archive;
 class BackupClientContext;

Modified: box/trunk/lib/server/Message.h
===================================================================
--- box/trunk/lib/server/Message.h	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/lib/server/Message.h	2014-08-15 22:47:14 UTC (rev 3352)
@@ -37,7 +37,7 @@
 
 	// reading and writing with Protocol objects
 	virtual void SetPropertiesFromStreamData(Protocol &rProtocol);
-	virtual void WritePropertiesToStreamData(Protocol &rProtocol) const;	
+	virtual void WritePropertiesToStreamData(Protocol &rProtocol) const;
 
 	virtual void LogSysLog(const char *Action) const { }
 	virtual void LogFile(const char *Action, FILE *file) const { }

Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp	2014-08-15 22:47:10 UTC (rev 3351)
+++ box/trunk/test/bbackupd/testbbackupd.cpp	2014-08-15 22:47:14 UTC (rev 3352)
@@ -1483,7 +1483,7 @@
 			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context, 0 /* read-write */);
 		
-			std::auto_ptr<BackupStoreDirectory> rootDir = 
+			std::auto_ptr<BackupStoreDirectory> rootDir =
 				ReadDirectory(*client);
 
 			int64_t testDirId = SearchDir(*rootDir, "Test1");
@@ -1492,7 +1492,7 @@
 			std::auto_ptr<BackupStoreDirectory> Test1_dir =
 				ReadDirectory(*client, testDirId);
 
-			int64_t spacetestDirId = SearchDir(*Test1_dir, 
+			int64_t spacetestDirId = SearchDir(*Test1_dir,
 				"spacetest");
 			TEST_THAT(spacetestDirId != 0);
 
@@ -1526,18 +1526,12 @@
 				ReadDirectory(*client, d4_id);
 			TEST_THAT(test_entry_deleted(*d4_dir, "f5"));
 
-			std::auto_ptr<BackupProtocolAccountUsage> usage(
-				client->QueryGetAccountUsage());
-			TEST_EQUAL_LINE(24, usage->GetBlocksUsed(),
-				"blocks used");
-			TEST_EQUAL_LINE(4, usage->GetBlocksInDeletedFiles(),
-				"deleted blocks");
-			TEST_EQUAL_LINE(16, usage->GetBlocksInDirectories(),
-				"directory blocks");
 			// d1/f3 and d1/f4 are the only two files on the
 			// server which are not deleted, they use 2 blocks
 			// each, the rest is directories and 2 deleted files
-			// (f1 and d3/d4/f5)
+			// (f2 and d3/d4/f5)
+			TEST_THAT(check_num_files(2, 0, 2, 8));
+			TEST_THAT(check_num_blocks(*client, 4, 0, 4, 16, 24));
 
 			// Log out.
 			client->QueryFinished();
@@ -1546,15 +1540,22 @@
 
 		if (failures) return 1;
 
+#ifdef WIN32
+		// Housekeeping runs automatically at the end of each backup,
+		// and didn't run last time (see comments above), so run it
+		// manually.
+		TEST_THAT(run_housekeeping_and_check_account());
+#else
 		wait_for_operation(5, "housekeeping to remove the "
 			"deleted files");
+#endif
 
 		BOX_TRACE("Check that the files were removed");
 		{
-			std::auto_ptr<BackupProtocolClient> client = 
+			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context, 0 /* read-write */);
-			
-			std::auto_ptr<BackupStoreDirectory> rootDir = 
+
+			std::auto_ptr<BackupStoreDirectory> rootDir =
 				ReadDirectory(*client);
 
 			int64_t testDirId = SearchDir(*rootDir, "Test1");
@@ -1563,7 +1564,7 @@
 			std::auto_ptr<BackupStoreDirectory> Test1_dir =
 				ReadDirectory(*client, testDirId);
 
-			int64_t spacetestDirId = SearchDir(*Test1_dir, 
+			int64_t spacetestDirId = SearchDir(*Test1_dir,
 				"spacetest");
 			TEST_THAT(spacetestDirId != 0);
 
@@ -1611,7 +1612,7 @@
 
 		// BLOCK
 		{
-			std::auto_ptr<BackupProtocolClient> client = 
+			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context, 0 /* read-write */);
 
 			std::auto_ptr<BackupProtocolAccountUsage> usage(




More information about the Boxbackup-commit mailing list