[Box Backup-commit] COMMIT r2419 - box/trunk/bin/bbackupquery
boxbackup-dev at boxbackup.org
boxbackup-dev at boxbackup.org
Wed Dec 31 14:37:41 GMT 2008
Author: chris
Date: 2008-12-31 14:37:40 +0000 (Wed, 31 Dec 2008)
New Revision: 2419
Modified:
box/trunk/bin/bbackupquery/BackupQueries.cpp
box/trunk/bin/bbackupquery/BackupQueries.h
box/trunk/bin/bbackupquery/BoxBackupCompareParams.h
Log:
Compare interface tweaks to reduce the number of methods.
Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp 2008-12-30 18:31:52 UTC (rev 2418)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2008-12-31 14:37:40 UTC (rev 2419)
@@ -1483,8 +1483,13 @@
localAttr.ReadAttributes(rLocalDir.c_str(),
true /* directories have zero mod times */);
- if(!(attr.Compare(localAttr, true, true /* ignore modification times */)))
+ if(attr.Compare(localAttr, true, true /* ignore modification times */))
{
+ rParams.NotifyDirCompared(rLocalDir, rStoreDir,
+ false, false /* actually we didn't check :) */);
+ }
+ else
+ {
bool modifiedAfterLastSync = false;
struct stat st;
@@ -1497,8 +1502,8 @@
}
}
- rParams.NotifyDifferentAttributes(rLocalDir, rStoreDir,
- modifiedAfterLastSync, false);
+ rParams.NotifyDirCompared(rLocalDir, rStoreDir,
+ true, modifiedAfterLastSync);
}
}
@@ -1627,6 +1632,14 @@
}
else
{
+ int64_t fileSize = 0;
+
+ struct stat st;
+ if(::stat(localPath.c_str(), &st) == 0)
+ {
+ fileSize = st.st_size;
+ }
+
try
{
// Files the same flag?
@@ -1635,7 +1648,7 @@
// File modified after last sync flag
bool modifiedAfterLastSync = false;
- bool hasDifferentAttribsOrContents = false;
+ bool hasDifferentAttribs = false;
if(rParams.QuickCompare())
{
@@ -1699,12 +1712,7 @@
ignoreAttrModTime,
fileOnServerStream->IsSymLink() /* ignore modification time if it's a symlink */))
{
- rParams.NotifyDifferentAttributes(
- localPath,
- storePath,
- modifiedAfterLastSync,
- i->second->HasAttributes());
- hasDifferentAttribsOrContents = true;
+ hasDifferentAttribs = true;
}
// Compare contents, if it's a regular file not a link
@@ -1747,35 +1755,26 @@
}
}
- // Report if not equal.
- if(!equal)
- {
- rParams.NotifyDifferentContents(
- localPath, storePath,
- modifiedAfterLastSync);
- hasDifferentAttribsOrContents = true;
- }
-
- if (!hasDifferentAttribsOrContents)
- {
- rParams.NotifyFileCompareOK(
- localPath, storePath);
- }
+ rParams.NotifyFileCompared(localPath,
+ storePath, fileSize,
+ hasDifferentAttribs, !equal,
+ modifiedAfterLastSync,
+ i->second->HasAttributes());
}
catch(BoxException &e)
{
rParams.NotifyDownloadFailed(localPath,
- storePath, e);
+ storePath, fileSize, e);
}
catch(std::exception &e)
{
rParams.NotifyDownloadFailed(localPath,
- storePath, e);
+ storePath, fileSize, e);
}
catch(...)
{
rParams.NotifyDownloadFailed(localPath,
- storePath);
+ storePath, fileSize);
}
// Remove from set so that we know it's been compared
Modified: box/trunk/bin/bbackupquery/BackupQueries.h
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.h 2008-12-30 18:31:52 UTC (rev 2418)
+++ box/trunk/bin/bbackupquery/BackupQueries.h 2008-12-31 14:37:40 UTC (rev 2419)
@@ -127,32 +127,6 @@
"doesn't have attributes.");
}
- virtual void NotifyDifferentAttributes(
- const std::string& rLocalPath,
- const std::string& rRemotePath,
- bool modifiedAfterLastSync,
- bool newAttributesApplied)
- {
- BOX_WARNING("Local file '" <<
- ConvertForConsole(rLocalPath) <<
- "' has different attributes to store file '" <<
- ConvertForConsole(rRemotePath) << "'.");
- mDifferences ++;
-
- if(modifiedAfterLastSync)
- {
- mDifferencesExplainedByModTime ++;
- BOX_INFO("(the file above was modified after "
- "the last sync time -- might be "
- "reason for difference)");
- }
- else if(newAttributesApplied)
- {
- BOX_INFO("(the file above has had new "
- "attributes applied)\n");
- }
- }
-
virtual void NotifyRemoteFileMissing(
const std::string& rLocalPath,
const std::string& rRemotePath,
@@ -197,28 +171,8 @@
mDifferences ++;
}
- virtual void NotifyDifferentContents(
- const std::string& rLocalPath,
- const std::string& rRemotePath,
- bool modifiedAfterLastSync)
- {
- BOX_WARNING("Local file '" <<
- ConvertForConsole(rLocalPath) <<
- "' has different contents to store file '" <<
- ConvertForConsole(rRemotePath) << "'.");
- mDifferences ++;
-
- if(modifiedAfterLastSync)
- {
- mDifferencesExplainedByModTime ++;
- BOX_INFO("(the file above was modified after "
- "the last sync time -- might be "
- "reason for difference)");
- }
- }
-
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath,
+ const std::string& rRemotePath, int64_t NumBytes,
BoxException& rException)
{
BOX_ERROR("Failed to download remote file '" <<
@@ -230,7 +184,7 @@
}
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath,
+ const std::string& rRemotePath, int64_t NumBytes,
std::exception& rException)
{
BOX_ERROR("Failed to download remote file '" <<
@@ -240,7 +194,7 @@
}
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath)
+ const std::string& rRemotePath, int64_t NumBytes)
{
BOX_ERROR("Failed to download remote file '" <<
ConvertForConsole(rRemotePath));
@@ -259,10 +213,78 @@
mExcludedDirs ++;
}
- virtual void NotifyFileCompareOK(const std::string& rLocalPath,
- const std::string& rRemotePath)
+ virtual void NotifyDirCompared(
+ const std::string& rLocalPath,
+ const std::string& rRemotePath,
+ bool HasDifferentAttributes,
+ bool modifiedAfterLastSync)
{
+ if(HasDifferentAttributes)
+ {
+ BOX_WARNING("Local directory '" <<
+ ConvertForConsole(rLocalPath) << "' "
+ "has different attributes to "
+ "store directory '" <<
+ ConvertForConsole(rRemotePath) << "'.");
+ mDifferences ++;
+
+ if(modifiedAfterLastSync)
+ {
+ mDifferencesExplainedByModTime ++;
+ BOX_INFO("(the directory above was "
+ "modified after the last sync "
+ "time -- might be reason for "
+ "difference)");
+ }
+ }
}
+
+ virtual void NotifyFileCompared(const std::string& rLocalPath,
+ const std::string& rRemotePath, int64_t NumBytes,
+ bool HasDifferentAttributes, bool HasDifferentContents,
+ bool ModifiedAfterLastSync, bool NewAttributesApplied)
+ {
+ int NewDifferences = 0;
+
+ if(HasDifferentAttributes)
+ {
+ BOX_WARNING("Local file '" <<
+ ConvertForConsole(rLocalPath) << "' "
+ "has different attributes to "
+ "store file '" <<
+ ConvertForConsole(rRemotePath) << "'.");
+ NewDifferences ++;
+ }
+
+ if(HasDifferentContents)
+ {
+ BOX_WARNING("Local file '" <<
+ ConvertForConsole(rLocalPath) << "' "
+ "has different contents to "
+ "store file '" <<
+ ConvertForConsole(rRemotePath) << "'.");
+ NewDifferences ++;
+ }
+
+ if(HasDifferentAttributes || HasDifferentContents)
+ {
+ if(ModifiedAfterLastSync)
+ {
+ mDifferencesExplainedByModTime +=
+ NewDifferences;
+ BOX_INFO("(the file above was modified "
+ "after the last sync time -- "
+ "might be reason for difference)");
+ }
+ else if(NewAttributesApplied)
+ {
+ BOX_INFO("(the file above has had new "
+ "attributes applied)\n");
+ }
+ }
+
+ mDifferences += NewDifferences;
+ }
};
void CompareLocation(const std::string &rLocation,
BoxBackupCompareParams &rParams);
Modified: box/trunk/bin/bbackupquery/BoxBackupCompareParams.h
===================================================================
--- box/trunk/bin/bbackupquery/BoxBackupCompareParams.h 2008-12-30 18:31:52 UTC (rev 2418)
+++ box/trunk/bin/bbackupquery/BoxBackupCompareParams.h 2008-12-31 14:37:40 UTC (rev 2419)
@@ -71,10 +71,6 @@
const std::string& rRemotePath) = 0;
virtual void NotifyStoreDirMissingAttributes(const std::string& rLocalPath,
const std::string& rRemotePath) = 0;
- virtual void NotifyDifferentAttributes(const std::string& rLocalPath,
- const std::string& rRemotePath,
- bool modifiedAfterLastSync,
- bool newAttributesApplied) = 0;
virtual void NotifyRemoteFileMissing(const std::string& rLocalPath,
const std::string& rRemotePath,
bool modifiedAfterLastSync) = 0;
@@ -82,23 +78,25 @@
const std::string& rRemotePath) = 0;
virtual void NotifyExcludedFileNotDeleted(const std::string& rLocalPath,
const std::string& rRemotePath) = 0;
- virtual void NotifyDifferentContents(const std::string& rLocalPath,
- const std::string& rRemotePath,
- bool modifiedAfterLastSync) = 0;
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath,
+ const std::string& rRemotePath, int64_t NumBytes,
BoxException& rException) = 0;
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath,
+ const std::string& rRemotePath, int64_t NumBytes,
std::exception& rException) = 0;
virtual void NotifyDownloadFailed(const std::string& rLocalPath,
- const std::string& rRemotePath) = 0;
+ const std::string& rRemotePath, int64_t NumBytes) = 0;
virtual void NotifyExcludedFile(const std::string& rLocalPath,
const std::string& rRemotePath) = 0;
virtual void NotifyExcludedDir(const std::string& rLocalPath,
const std::string& rRemotePath) = 0;
- virtual void NotifyFileCompareOK(const std::string& rLocalPath,
- const std::string& rRemotePath) = 0;
+ virtual void NotifyDirCompared(const std::string& rLocalPath,
+ const std::string& rRemotePath, bool HasDifferentAttributes,
+ bool modifiedAfterLastSync) = 0;
+ virtual void NotifyFileCompared(const std::string& rLocalPath,
+ const std::string& rRemotePath, int64_t NumBytes,
+ bool HasDifferentAttributes, bool HasDifferentContents,
+ bool modifiedAfterLastSync, bool newAttributesApplied) = 0;
};
#endif // BOXBACKUPCOMPAREPARAMS__H
More information about the Boxbackup-commit
mailing list