From c65bbcc2c29c30e2fa755059e48d07a07f6b4c07 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 21 Aug 2008 11:14:23 +0000 Subject: Use SelfFlushingStream to ensure that protocol streams are always flushed, fixes a problem where local file is not readable during compare, and stream was not flushed, breaking the rest of the compare. --- bin/bbackupquery/BackupQueries.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 6b0bef82..1a183599 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -1709,8 +1709,11 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s // Compare contents, if it's a regular file not a link // Remember, we MUST read the entire stream from the server. + SelfFlushingStream flushObject(*objectStream); + if(!fileOnServerStream->IsSymLink()) { + SelfFlushingStream flushFile(*fileOnServerStream); // Open the local file FileStream l(localPath.c_str()); @@ -1741,28 +1744,6 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s { equal = false; } - - // Must always read the entire decoded stream, if it's not a symlink - if(fileOnServerStream->StreamDataLeft()) - { - // Absorb all the data remaining - char buffer[2048]; - while(fileOnServerStream->StreamDataLeft()) - { - fileOnServerStream->Read(buffer, sizeof(buffer), mrConnection.GetTimeout()); - } - } - - // Must always read the entire encoded stream - if(objectStream->StreamDataLeft()) - { - // Absorb all the data remaining - char buffer[2048]; - while(objectStream->StreamDataLeft()) - { - objectStream->Read(buffer, sizeof(buffer), mrConnection.GetTimeout()); - } - } } } -- cgit v1.2.3