[Box Backup-commit] COMMIT r2804 - in box/trunk: . bin/bbackupd lib/backupclient

subversion at boxbackup.org subversion at boxbackup.org
Wed Nov 17 09:49:40 GMT 2010


Author: chris
Date: 2010-11-17 09:49:39 +0000 (Wed, 17 Nov 2010)
New Revision: 2804

Modified:
   box/trunk/
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/trunk/bin/bbackupd/BackupDaemon.h
   box/trunk/bin/bbackupd/BackupDaemonInterface.h
   box/trunk/lib/backupclient/BackupStoreFile.cpp
   box/trunk/lib/backupclient/BackupStoreFile.h
   box/trunk/lib/backupclient/BackupStoreFileEncodeStream.cpp
   box/trunk/lib/backupclient/BackupStoreFileEncodeStream.h
Log:
Log the total number of bytes uploaded to the server for each file.



Property changes on: box/trunk
___________________________________________________________________
Added: svn:mergeinfo
   + /box/RELEASE/0.11rc5:2575

Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2010-11-17 09:49:39 UTC (rev 2804)
@@ -17,9 +17,10 @@
 #include <errno.h>
 #include <string.h>
 
+#include "autogen_BackupProtocolClient.h"
 #include "BackupClientDirectoryRecord.h"
-#include "autogen_BackupProtocolClient.h"
 #include "BackupClientContext.h"
+#include "BackupStoreFileEncodeStream.h"
 #include "IOStream.h"
 #include "MemBlockStream.h"
 #include "CommonException.h"
@@ -1513,6 +1514,7 @@
 	// Info
 	int64_t objID = 0;
 	bool doNormalUpload = true;
+	int64_t uploadedSize = -1;
 	
 	// Use a try block to catch store full errors
 	try
@@ -1543,6 +1545,7 @@
 				rContext.ManageDiffProcess();
 
 				bool isCompletelyDifferent = false;
+
 				std::auto_ptr<IOStream> patchStream(
 					BackupStoreFile::EncodeFileDiff(
 						rFilename.c_str(),
@@ -1566,6 +1569,10 @@
 
 				// Don't attempt to upload it again!
 				doNormalUpload = false;
+
+				// Capture number of bytes sent
+				uploadedSize = ((BackupStoreFileEncodeStream &)
+					*patchStream).GetTotalBytesSent();
 			} 
 		}
 	
@@ -1591,6 +1598,9 @@
 	
 			// Get object ID from the result		
 			objID = stored->GetObjectID();
+
+			uploadedSize = ((BackupStoreFileEncodeStream &)
+				*upload).GetTotalBytesSent();
 		}
 	}
 	catch(BoxException &e)
@@ -1625,7 +1635,7 @@
 		throw;
 	}
 
-	rNotifier.NotifyFileUploaded(this, rFilename, FileSize);
+	rNotifier.NotifyFileUploaded(this, rFilename, FileSize, uploadedSize);
 
 	// Return the new object ID of this file
 	return objID;

Modified: box/trunk/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.h	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/bin/bbackupd/BackupDaemon.h	2010-11-17 09:49:39 UTC (rev 2804)
@@ -457,11 +457,13 @@
  	virtual void NotifyFileUploaded(
  		const BackupClientDirectoryRecord* pDirRecord,
  		const std::string& rLocalPath,
- 		int64_t FileSize) 
+ 		int64_t FileSize, int64_t UploadedSize) 
 	{
 		if (mLogAllFileAccess)
 		{
-			BOX_NOTICE("Uploaded file: " << rLocalPath);
+			BOX_NOTICE("Uploaded file: " << rLocalPath << ", "
+				"total size = " << FileSize << ", "
+				"uploaded size = " << UploadedSize);
 		} 
 	}
  	virtual void NotifyFileSynchronised(

Modified: box/trunk/bin/bbackupd/BackupDaemonInterface.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemonInterface.h	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/bin/bbackupd/BackupDaemonInterface.h	2010-11-17 09:49:39 UTC (rev 2804)
@@ -129,7 +129,7 @@
 	virtual void NotifyFileUploaded(
 		const BackupClientDirectoryRecord* pDirRecord,
 		const std::string& rLocalPath,
-		int64_t FileSize) = 0;
+		int64_t FileSize, int64_t UploadedSize) = 0;
 	virtual void NotifyFileSynchronised(
 		const BackupClientDirectoryRecord* pDirRecord,
 		const std::string& rLocalPath,

Modified: box/trunk/lib/backupclient/BackupStoreFile.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFile.cpp	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/lib/backupclient/BackupStoreFile.cpp	2010-11-17 09:49:39 UTC (rev 2804)
@@ -73,9 +73,11 @@
 //		Created: 2003/08/28
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<IOStream> BackupStoreFile::EncodeFile(const char *Filename,
-	int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
-	int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger,
+std::auto_ptr<IOStream> BackupStoreFile::EncodeFile(
+	const char *Filename, int64_t ContainerID,
+	const BackupStoreFilename &rStoreFilename,
+	int64_t *pModificationTime,
+	ReadLoggingStream::Logger* pLogger,
 	RunStatusProvider* pRunStatusProvider)
 {
 	// Create the stream

Modified: box/trunk/lib/backupclient/BackupStoreFile.h
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFile.h	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/lib/backupclient/BackupStoreFile.h	2010-11-17 09:49:39 UTC (rev 2804)
@@ -118,11 +118,14 @@
 
 
 	// Main interface
-	static std::auto_ptr<IOStream> EncodeFile(const char *Filename,
+	static std::auto_ptr<IOStream> EncodeFile
+	(
+		const char *Filename,
 		int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
 		int64_t *pModificationTime = 0,
 		ReadLoggingStream::Logger* pLogger = NULL,
-		RunStatusProvider* pRunStatusProvider = NULL);
+		RunStatusProvider* pRunStatusProvider = NULL
+	);
 	static std::auto_ptr<IOStream> EncodeFileDiff
 	(
 		const char *Filename, int64_t ContainerID,

Modified: box/trunk/lib/backupclient/BackupStoreFileEncodeStream.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFileEncodeStream.cpp	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/lib/backupclient/BackupStoreFileEncodeStream.cpp	2010-11-17 09:49:39 UTC (rev 2804)
@@ -55,6 +55,7 @@
 	  mPositionInCurrentBlock(0),
 	  mBlockSize(BACKUP_FILE_MIN_BLOCK_SIZE),
 	  mLastBlockSize(0),
+	  mTotalBytesSent(0),
 	  mpRawBuffer(0),
 	  mAllocatedBufferSize(0),
 	  mEntryIVBase(0)
@@ -463,6 +464,7 @@
 	
 	// Add encoded size to stats
 	BackupStoreFile::msStats.mTotalFileStreamSize += (NBytes - bytesToRead);
+	mTotalBytesSent += (NBytes - bytesToRead);
 	
 	// Return size of data to caller
 	return NBytes - bytesToRead;

Modified: box/trunk/lib/backupclient/BackupStoreFileEncodeStream.h
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFileEncodeStream.h	2010-11-06 20:30:15 UTC (rev 2803)
+++ box/trunk/lib/backupclient/BackupStoreFileEncodeStream.h	2010-11-17 09:49:39 UTC (rev 2804)
@@ -85,6 +85,7 @@
 	virtual void Write(const void *pBuffer, int NBytes);
 	virtual bool StreamDataLeft();
 	virtual bool StreamClosed();
+	int64_t GetTotalBytesSent() { return mTotalBytesSent; }
 
 private:
 	enum
@@ -121,6 +122,7 @@
 	int32_t mPositionInCurrentBlock;	// for reading out
 	int32_t mBlockSize;					// Basic block size of most of the blocks in the file
 	int32_t mLastBlockSize;				// the size (unencoded) of the last block in the file
+	int64_t mTotalBytesSent;
 	// Buffers
 	uint8_t *mpRawBuffer;				// buffer for raw data
 	BackupStoreFile::EncodingBuffer mEncodedBuffer;




More information about the Boxbackup-commit mailing list