diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-08-15 22:47:14 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-08-15 22:47:14 +0000 |
commit | 732370e12192a3b66a8b0a3e1f66eed3ebcdc3d3 (patch) | |
tree | e3366037c0f7d1de484b8a3ffcd08cf33daf32e0 | |
parent | 8cde77d5f4bf894b37197552bd9b035cfcf57a22 (diff) |
Whitespace, wrapping, comments and dead code cleanups.
Conflicts:
bin/bbackupd/BackupDaemon.cpp
bin/bbackupd/BackupDaemon.h
test/bbackupd/testbbackupd.cpp
-rw-r--r-- | bin/bbackupd/BackupClientContext.cpp | 4 | ||||
-rw-r--r-- | bin/bbackupd/BackupClientDirectoryRecord.cpp | 18 | ||||
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 12 | ||||
-rw-r--r-- | bin/bbackupd/BackupDaemon.h | 146 | ||||
-rw-r--r-- | bin/bbackupd/BackupDaemonInterface.h | 6 | ||||
-rw-r--r-- | lib/server/Message.h | 2 | ||||
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 33 |
7 files changed, 108 insertions, 113 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index ca4200c4..5025bf5c 100644 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -126,8 +126,8 @@ BackupProtocolClient &BackupClientContext::GetConnection() mapConnection.reset(); // Log intention - BOX_INFO("Opening connection to server '" << - mHostname << "'..."); + BOX_INFO("Opening connection to server '" << mHostname << + "'..."); // Connect! ((SocketStreamTLS *)(apSocket.get()))->Open(mrTLSContext, diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp index e8dddd6f..820cfbaf 100644 --- a/bin/bbackupd/BackupClientDirectoryRecord.cpp +++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp @@ -1368,7 +1368,7 @@ bool BackupClientDirectoryRecord::UpdateItems( // 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 @@ bool BackupClientDirectoryRecord::UpdateItems( 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 @@ bool BackupClientDirectoryRecord::UpdateItems( { // New an object for this psubDirRecord = new BackupClientDirectoryRecord(subDirObjectID, *d); - + // Store in list try { @@ -1547,7 +1547,7 @@ bool BackupClientDirectoryRecord::UpdateItems( 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 @@ bool BackupClientDirectoryRecord::UpdateItems( 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 @@ bool BackupClientDirectoryRecord::UpdateItems( 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 @@ bool BackupClientDirectoryRecord::UpdateItems( BOX_TRACE("Deleted directory record for " << nonVssLocalName); - } + } } } } @@ -1778,7 +1778,7 @@ int64_t BackupClientDirectoryRecord::UploadFile( rContext.SetNiceMode(false); - // Get object ID from the result + // Get object ID from the result objID = stored->GetObjectID(); uploadedSize = apStreamToUpload->GetTotalBytesSent(); } diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index 8aeb18b2..3d352286 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -858,13 +858,13 @@ void BackupDaemon::RunSyncNow() { 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,14 +872,14 @@ void BackupDaemon::RunSyncNow() mTlsContext, conf.GetKeyValue("StoreHostname"), conf.GetKeyValueInt("StorePort"), - conf.GetKeyValueUint32("AccountNumber"), + conf.GetKeyValueUint32("AccountNumber"), conf.GetKeyValueBool("ExtendedLogging"), conf.KeyExists("ExtendedLogFile"), extendedLogFile, *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 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con // 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 diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h index 5a811f7e..7b1771fa 100644 --- a/bin/bbackupd/BackupDaemon.h +++ b/bin/bbackupd/BackupDaemon.h @@ -196,10 +196,10 @@ private: #endif IOStreamGetLine *mpGetLine; }; - + // Using a socket? std::auto_ptr<CommandSocketInfo> mapCommandSocketInfo; - + // Stop notifications being repeated. SysadminNotifier::EventCode mLastNotifiedEvent; @@ -220,7 +220,7 @@ private: 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 @@ private: 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 @@ public: 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 @@ public: if (mLogAllFileAccess) { BOX_INFO("Skipping excluded file: " << rLocalPath); - } + } } virtual void NotifyDirExcluded( const BackupClientDirectoryRecord* pDirRecord, @@ -318,7 +318,7 @@ public: if (mLogAllFileAccess) { BOX_INFO("Skipping excluded directory: " << rLocalPath); - } + } } virtual void NotifyUnsupportedFileType( const BackupClientDirectoryRecord* pDirRecord, @@ -326,43 +326,43 @@ public: { 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 @@ public: } } - 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 @@ public: } 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 @@ public: { if (mLogAllFileAccess) { - BOX_NOTICE("Created directory: " << rRemotePath << + BOX_NOTICE("Created directory: " << rRemotePath << " (ID " << BOX_FORMAT_OBJECTID(ObjectID) << ")"); } diff --git a/bin/bbackupd/BackupDaemonInterface.h b/bin/bbackupd/BackupDaemonInterface.h index a847b264..2e603b96 100644 --- a/bin/bbackupd/BackupDaemonInterface.h +++ b/bin/bbackupd/BackupDaemonInterface.h @@ -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; diff --git a/lib/server/Message.h b/lib/server/Message.h index c6fa3cc1..9f2245ec 100644 --- a/lib/server/Message.h +++ b/lib/server/Message.h @@ -37,7 +37,7 @@ public: // 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 { } diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 46289808..7a68a28b 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -1483,7 +1483,7 @@ int test_bbackupd() 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 @@ int test_bbackupd() 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 @@ int test_bbackupd() 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 @@ int test_bbackupd() 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 @@ int test_bbackupd() 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 @@ int test_bbackupd() // BLOCK { - std::auto_ptr<BackupProtocolClient> client = + std::auto_ptr<BackupProtocolClient> client = ConnectAndLogin(context, 0 /* read-write */); std::auto_ptr<BackupProtocolAccountUsage> usage( |