summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/bbackupquery/BackupQueries.cpp53
-rw-r--r--bin/bbackupquery/BackupQueries.h124
-rw-r--r--bin/bbackupquery/BoxBackupCompareParams.h22
3 files changed, 109 insertions, 90 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index a6d5fa68..76ecfcf8 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -1483,7 +1483,12 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
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;
@@ -1497,8 +1502,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
}
}
- rParams.NotifyDifferentAttributes(rLocalDir, rStoreDir,
- modifiedAfterLastSync, false);
+ rParams.NotifyDirCompared(rLocalDir, rStoreDir,
+ true, modifiedAfterLastSync);
}
}
@@ -1627,6 +1632,14 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
}
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 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
// File modified after last sync flag
bool modifiedAfterLastSync = false;
- bool hasDifferentAttribsOrContents = false;
+ bool hasDifferentAttribs = false;
if(rParams.QuickCompare())
{
@@ -1699,12 +1712,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
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 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir,
}
}
- // 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
diff --git a/bin/bbackupquery/BackupQueries.h b/bin/bbackupquery/BackupQueries.h
index 75cd2469..0744a1c3 100644
--- a/bin/bbackupquery/BackupQueries.h
+++ b/bin/bbackupquery/BackupQueries.h
@@ -127,32 +127,6 @@ public:
"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 @@ public:
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 @@ public:
}
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 @@ public:
}
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,9 +213,77 @@ public:
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,
diff --git a/bin/bbackupquery/BoxBackupCompareParams.h b/bin/bbackupquery/BoxBackupCompareParams.h
index f9727122..d8c50fc3 100644
--- a/bin/bbackupquery/BoxBackupCompareParams.h
+++ b/bin/bbackupquery/BoxBackupCompareParams.h
@@ -71,10 +71,6 @@ public:
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 @@ public:
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