[Box Backup-commit] COMMIT r2754 - in box/trunk: bin/bbackupquery test/bbackupd

subversion at boxbackup.org subversion at boxbackup.org
Wed Sep 22 22:12:03 BST 2010


Author: chris
Date: 2010-09-22 22:12:02 +0100 (Wed, 22 Sep 2010)
New Revision: 2754

Modified:
   box/trunk/bin/bbackupquery/BackupQueries.cpp
   box/trunk/bin/bbackupquery/documentation.txt
   box/trunk/test/bbackupd/testbbackupd.cpp
Log:
Allow restoring directories with a single argument, using the remote name
as the local destination name also.


Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp	2010-09-22 19:29:52 UTC (rev 2753)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp	2010-09-22 21:12:02 UTC (rev 2754)
@@ -1951,9 +1951,10 @@
 void BackupQueries::CommandRestore(const std::vector<std::string> &args, const bool *opts)
 {
 	// Check arguments
-	if(args.size() != 2)
+	if(args.size() < 1 || args.size() > 2)
 	{
-		BOX_ERROR("Incorrect usage. restore [-drif] <remote-name> <local-name>");
+		BOX_ERROR("Incorrect usage. restore [-drif] <remote-name> "
+			"[<local-name>]");
 		return;
 	}
 
@@ -1994,19 +1995,31 @@
 		BOX_ERROR("Directory '" << args[0] << "' not found on server");
 		return;
 	}
+
 	if(dirID == BackupProtocolClientListDirectory::RootDirectory)
 	{
 		BOX_ERROR("Cannot restore the root directory -- restore locations individually.");
 		return;
 	}
-	
-#ifdef WIN32
+
 	std::string localName;
-	if(!ConvertConsoleToUtf8(args[1].c_str(), localName)) return;
-#else
-	std::string localName(args[1]);
-#endif
 
+	if(args.size() == 2)
+	{
+		#ifdef WIN32
+			if(!ConvertConsoleToUtf8(args[1].c_str(), localName))
+			{
+				return;
+			}
+		#else
+			localName = args[1];
+		#endif
+	}
+	else
+	{
+		localName = args[0];
+	}
+
 	// Go and restore...
 	int result;
 

Modified: box/trunk/bin/bbackupquery/documentation.txt
===================================================================
--- box/trunk/bin/bbackupquery/documentation.txt	2010-09-22 19:29:52 UTC (rev 2753)
+++ box/trunk/bin/bbackupquery/documentation.txt	2010-09-22 21:12:02 UTC (rev 2754)
@@ -119,10 +119,13 @@
 	This can be used for automated tests.
 <
 
-> restore [-drif] <directory-name> <local-directory-name>
+> restore [-drif] <directory-name> [<local-directory-name>]
 
 	Restores a directory to the local disc. The local directory specified
-	must not exist (unless a previous restore is being restarted).
+	must not exist (unless a previous restore is being restarted). If the
+	local directory is omitted, the default is to restore to the same
+	directory name and path, relative to the current local directory,
+	as set with the "lcd" command.
 
 	The root cannot be restored -- restore locations individually.
 

Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp	2010-09-22 19:29:52 UTC (rev 2753)
+++ box/trunk/test/bbackupd/testbbackupd.cpp	2010-09-22 21:12:02 UTC (rev 2754)
@@ -2070,6 +2070,31 @@
 				BackupQueries::ReturnCode::Compare_Same);
 			TestRemoteProcessMemLeaks("bbackupquery.memleaks");
 
+			// Try a restore with just the remote directory name,
+			// check that it uses the same name in the local
+			// directory.
+			TEST_THAT(::mkdir("testfiles/restore-test", 0700) == 0);
+
+			compareReturnValue = ::system(BBACKUPQUERY " "
+				"-Wwarning "
+				"-c testfiles/bbackupd.conf "
+				"\"lcd testfiles/restore-test\" "
+				"\"restore Test1\" "
+				"quit");
+			TEST_RETURN(compareReturnValue,
+				BackupQueries::ReturnCode::Command_OK);
+			TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+
+			// check that it restored properly
+			compareReturnValue = ::system(BBACKUPQUERY " "
+				"-Wwarning "
+				"-c testfiles/bbackupd.conf "
+				"\"compare -cEQ Test1 testfiles/restore-test/Test1\" " 
+				"quit");
+			TEST_RETURN(compareReturnValue,
+				BackupQueries::ReturnCode::Compare_Same);
+			TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+
 			// put the permissions back to sensible values
 			#ifdef WIN32
 				TEST_THAT(::system("chmod 0755 testfiles/"
@@ -2082,7 +2107,6 @@
 				TEST_THAT(chmod("testfiles/restore1/x1",
 					0755) == 0);
 			#endif
-
 		}
 
 #ifdef WIN32




More information about the Boxbackup-commit mailing list