diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 10:41:18 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 10:41:18 +0000 |
commit | 2019b57dcbba43e8b3feba9385aec4a25bfa55b2 (patch) | |
tree | a669d280e5a15a760f70e4a707b0dbdf03c79dcb /lib/common/ReadLoggingStream.cpp | |
parent | aad61cfb4d89c65cafc698da5aa1b6b06a5a232c (diff) |
Pass a RunStatusProvider and a ReadLoggingStream::Logger from
BackupDaemon through BackupClientDirectoryRecord, BackupStoreFile and
BackupStoreFileEncodeStream to ReadLoggingStream, to allow progress
callbacks during file upload and cancelling upload part-way.
Implement ReadLoggingStream::Logger in
BackupClientDirectoryRecord::SyncParams, which thunks the notifications
back to the ProgressNotifier.
Add the SysadminNotifier interface from Boxi.
Add NotifyIDMapsSetup() to ProgressNotifier.
Change BackupClientDirectoryRecord::SyncParams to store references to
the individual callback interfaces rather than BackupDaemon.
Initialise all members in BackupDaemon.
Add ability for BackupDaemon user to override the ProgressNotifier,
LocationResolver, SysadminNotifier and RunStatusProvider that will be
used during the backup.
Make BackupDaemon::Location class public and provide access to the
configured locations for Boxi (dangerous, they could be modified without
BackupDaemon knowing it).
Diffstat (limited to 'lib/common/ReadLoggingStream.cpp')
-rw-r--r-- | lib/common/ReadLoggingStream.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/common/ReadLoggingStream.cpp b/lib/common/ReadLoggingStream.cpp index 9023f827..54c99c95 100644 --- a/lib/common/ReadLoggingStream.cpp +++ b/lib/common/ReadLoggingStream.cpp @@ -25,12 +25,13 @@ // Created: 2007/01/16 // // -------------------------------------------------------------------------- -ReadLoggingStream::ReadLoggingStream(IOStream& rSource) +ReadLoggingStream::ReadLoggingStream(IOStream& rSource, Logger& rLogger) : mrSource(rSource), mOffset(0), mLength(mrSource.BytesLeftToRead()), mTotalRead(0), - mStartTime(GetCurrentBoxTime()) + mStartTime(GetCurrentBoxTime()), + mrLogger(rLogger) { } @@ -52,26 +53,21 @@ int ReadLoggingStream::Read(void *pBuffer, int NBytes, int Timeout) mOffset += numBytesRead; } - if (mLength >= 0 && mTotalRead > 0) + if (mLength == 0) { - box_time_t timeNow = GetCurrentBoxTime(); - box_time_t elapsed = timeNow - mStartTime; - box_time_t finish = (elapsed * mLength) / mTotalRead; - box_time_t remain = finish - elapsed; - - BOX_TRACE("Read " << numBytesRead << " bytes at " << mOffset << - ", " << (mLength - mOffset) << " remain, eta " << - BoxTimeToSeconds(remain) << "s"); + mrLogger.Log(numBytesRead, mOffset); } - else if (mLength >= 0 && mTotalRead == 0) + else if (mTotalRead == 0) { - BOX_TRACE("Read " << numBytesRead << " bytes at " << mOffset << - ", " << (mLength - mOffset) << " remain"); + mrLogger.Log(numBytesRead, mOffset, mLength); } else { - BOX_TRACE("Read " << numBytesRead << " bytes at " << mOffset << - ", unknown bytes remaining"); + box_time_t timeNow = GetCurrentBoxTime(); + box_time_t elapsed = timeNow - mStartTime; + box_time_t finish = (elapsed * mLength) / mTotalRead; + // box_time_t remain = finish - elapsed; + mrLogger.Log(numBytesRead, mOffset, mLength, elapsed, finish); } return numBytesRead; |