[Box Backup-commit] COMMIT r1266 - box/chris/merge/bin/bbackupquery

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Wed Jan 17 22:13:23 GMT 2007


Author: chris
Date: 2007-01-17 22:13:23 +0000 (Wed, 17 Jan 2007)
New Revision: 1266

Modified:
   box/chris/merge/bin/bbackupquery/BackupQueries.cpp
Log:
When comparing, don't recurse into excluded directories, as their contents
will not be on the store. 

Fix display of filenames during compare when backing up the root directory
(double slash) (refs #3)


Modified: box/chris/merge/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/chris/merge/bin/bbackupquery/BackupQueries.cpp	2007-01-17 21:59:13 UTC (rev 1265)
+++ box/chris/merge/bin/bbackupquery/BackupQueries.cpp	2007-01-17 22:13:23 UTC (rev 1266)
@@ -46,6 +46,7 @@
 #include "BackupStoreException.h"
 #include "ExcludeList.h"
 #include "BackupClientMakeExcludeList.h"
+#include "PathUtils.h"
 
 #include "MemLeakFindOn.h"
 
@@ -1400,9 +1401,8 @@
 			}
 
 #ifndef HAVE_VALID_DIRENT_D_TYPE
-			std::string fn(rLocalDir);
-			fn += DIRECTORY_SEPARATOR_ASCHAR;
-			fn += localDirEn->d_name;
+			std::string fn(MakeFullPath
+				(rLocalDir, localDirEn->d_name));
 			struct stat st;
 			if(::lstat(fn.c_str(), &st) != 0)
 			{
@@ -1486,10 +1486,12 @@
 			const std::string& fileNameDisplay(i->first);
 #endif
 
-			std::string localPathDisplay = localDirDisplay +
-				DIRECTORY_SEPARATOR + fileNameDisplay;
-			std::string storePathDisplay = storeDirDisplay +
-				"/" + fileNameDisplay;
+			std::string localPath(MakeFullPath
+				(rLocalDir, fileName));
+			std::string localPathDisplay(MakeFullPath
+				(localDirDisplay, fileNameDisplay));
+			std::string storePathDisplay
+				(storeDirDisplay + "/" + fileNameDisplay);
 
 			// Does the file exist locally?
 			string_set_iter_t local(localFiles.find(fileName));
@@ -1506,9 +1508,6 @@
 			{
 				try
 				{
-					// make local name of file for comparison
-					std::string localPath(rLocalDir + DIRECTORY_SEPARATOR + fileName);
-
 					// Files the same flag?
 					bool equal = true;
 					
@@ -1692,12 +1691,12 @@
 			const std::string& fileNameDisplay(*i);
 #endif
 
-			std::string localPath(rLocalDir + 
-				DIRECTORY_SEPARATOR + *i);
-			std::string localPathDisplay(localDirDisplay +
-				DIRECTORY_SEPARATOR + fileNameDisplay);
-			std::string storePathDisplay(storeDirDisplay +
-				"/" + fileNameDisplay);
+			std::string localPath(MakeFullPath
+				(rLocalDir, *i));
+			std::string localPathDisplay(MakeFullPath
+				(localDirDisplay, fileNameDisplay));
+			std::string storePathDisplay
+				(storeDirDisplay + "/" + fileNameDisplay);
 
 			// Should this be ignored (ie is excluded)?
 			if(rParams.mpExcludeFiles == 0 || 
@@ -1733,7 +1732,7 @@
 		localFiles.clear();
 		storeFiles.clear();
 		
-		// Now do the directories, recusively to check subdirectories
+		// Now do the directories, recursively to check subdirectories
 		for(std::set<std::pair<std::string, BackupStoreDirectory::Entry *> >::const_iterator i = storeDirs.begin(); i != storeDirs.end(); ++i)
 		{
 #ifdef WIN32
@@ -1747,26 +1746,44 @@
 			const std::string& subdirNameDisplay(i->first);
 #endif
 
-			std::string localPathDisplay = localDirDisplay +
-				DIRECTORY_SEPARATOR + subdirNameDisplay;
-			std::string storePathDisplay = storeDirDisplay +
-				"/" + subdirNameDisplay;
+			std::string localPath(MakeFullPath
+				(rLocalDir, i->first));
+			std::string localPathDisplay(MakeFullPath
+				(localDirDisplay, subdirNameDisplay));
+			std::string storePathDisplay
+				(storeDirDisplay + "/" + subdirNameDisplay);
 
 			// Does the directory exist locally?
 			string_set_iter_t local(localDirs.find(i->first));
-			if(local == localDirs.end())
+			if(local == localDirs.end() &&
+				rParams.mpExcludeDirs != NULL && 
+				rParams.mpExcludeDirs->IsExcluded(localPath))
 			{
 				// Not found -- report
+				printf("Local directory '%s' is excluded, but "
+					"store directory '%s' still exists.\n",
+					localPathDisplay.c_str(),
+					storePathDisplay.c_str());
+				rParams.mDifferences ++;
+			}
+			else if(local == localDirs.end())
+			{
+				// Not found -- report
 				printf("Local directory '%s' does not exist, "
 					"but store directory '%s' does.\n",
 					localPathDisplay.c_str(),
 					storePathDisplay.c_str());
 				rParams.mDifferences ++;
 			}
+			else if(rParams.mpExcludeDirs != NULL && 
+				rParams.mpExcludeDirs->IsExcluded(localPath))
+			{
+				// don't recurse into excluded directories
+			}
 			else
 			{
 				// Compare directory
-				Compare(i->second->GetObjectID(), rStoreDir + "/" + i->first, rLocalDir + DIRECTORY_SEPARATOR + i->first, rParams);
+				Compare(i->second->GetObjectID(), rStoreDir + "/" + i->first, localPath, rParams);
 				
 				// Remove from set so that we know it's been compared
 				localDirs.erase(local);
@@ -1786,15 +1803,15 @@
 			const std::string& fileNameDisplay(*i);
 #endif
 
-			std::string localPath = rLocalDir +
-				DIRECTORY_SEPARATOR + *i;
-			std::string storePath = rStoreDir +
-				"/" + *i;
+			std::string localPath(MakeFullPath
+				(rLocalDir, *i));
+			std::string localPathDisplay(MakeFullPath
+				(localDirDisplay, fileNameDisplay));
 
-			std::string localPathDisplay = localDirDisplay +
-				DIRECTORY_SEPARATOR + fileNameDisplay;
-			std::string storePathDisplay = storeDirDisplay +
-				"/" + fileNameDisplay;
+			std::string storePath
+				(rStoreDir + "/" + *i);
+			std::string storePathDisplay
+				(storeDirDisplay + "/" + fileNameDisplay);
 
 			// Should this be ignored (ie is excluded)?
 			if(rParams.mpExcludeDirs == 0 || !(rParams.mpExcludeDirs->IsExcluded(localPath)))




More information about the Boxbackup-commit mailing list