summaryrefslogtreecommitdiff
path: root/bin/bbackupquery/BackupQueries.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbackupquery/BackupQueries.cpp')
-rw-r--r--bin/bbackupquery/BackupQueries.cpp79
1 files changed, 48 insertions, 31 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index 9c6168d8..ad4aeb93 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -46,6 +46,7 @@
#include "BackupStoreException.h"
#include "ExcludeList.h"
#include "BackupClientMakeExcludeList.h"
+#include "PathUtils.h"
#include "MemLeakFindOn.h"
@@ -1400,9 +1401,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
}
#ifndef HAVE_VALID_DIRENT_D_TYPE
- std::string fn(rLocalDir);
- fn += DIRECTORY_SEPARATOR_ASCHAR;
- fn += localDirEn->d_name;
+ std::string fn(MakeFullPath
+ (rLocalDir, localDirEn->d_name));
struct stat st;
if(::lstat(fn.c_str(), &st) != 0)
{
@@ -1486,10 +1486,12 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
const std::string& fileNameDisplay(i->first);
#endif
- std::string localPathDisplay = localDirDisplay +
- DIRECTORY_SEPARATOR + fileNameDisplay;
- std::string storePathDisplay = storeDirDisplay +
- "/" + fileNameDisplay;
+ std::string localPath(MakeFullPath
+ (rLocalDir, fileName));
+ std::string localPathDisplay(MakeFullPath
+ (localDirDisplay, fileNameDisplay));
+ std::string storePathDisplay
+ (storeDirDisplay + "/" + fileNameDisplay);
// Does the file exist locally?
string_set_iter_t local(localFiles.find(fileName));
@@ -1506,9 +1508,6 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
{
try
{
- // make local name of file for comparison
- std::string localPath(rLocalDir + DIRECTORY_SEPARATOR + fileName);
-
// Files the same flag?
bool equal = true;
@@ -1692,12 +1691,12 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
const std::string& fileNameDisplay(*i);
#endif
- std::string localPath(rLocalDir +
- DIRECTORY_SEPARATOR + *i);
- std::string localPathDisplay(localDirDisplay +
- DIRECTORY_SEPARATOR + fileNameDisplay);
- std::string storePathDisplay(storeDirDisplay +
- "/" + fileNameDisplay);
+ std::string localPath(MakeFullPath
+ (rLocalDir, *i));
+ std::string localPathDisplay(MakeFullPath
+ (localDirDisplay, fileNameDisplay));
+ std::string storePathDisplay
+ (storeDirDisplay + "/" + fileNameDisplay);
// Should this be ignored (ie is excluded)?
if(rParams.mpExcludeFiles == 0 ||
@@ -1733,7 +1732,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
localFiles.clear();
storeFiles.clear();
- // Now do the directories, recusively to check subdirectories
+ // Now do the directories, recursively to check subdirectories
for(std::set<std::pair<std::string, BackupStoreDirectory::Entry *> >::const_iterator i = storeDirs.begin(); i != storeDirs.end(); ++i)
{
#ifdef WIN32
@@ -1747,14 +1746,27 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
const std::string& subdirNameDisplay(i->first);
#endif
- std::string localPathDisplay = localDirDisplay +
- DIRECTORY_SEPARATOR + subdirNameDisplay;
- std::string storePathDisplay = storeDirDisplay +
- "/" + subdirNameDisplay;
+ std::string localPath(MakeFullPath
+ (rLocalDir, i->first));
+ std::string localPathDisplay(MakeFullPath
+ (localDirDisplay, subdirNameDisplay));
+ std::string storePathDisplay
+ (storeDirDisplay + "/" + subdirNameDisplay);
// Does the directory exist locally?
string_set_iter_t local(localDirs.find(i->first));
- if(local == localDirs.end())
+ if(local == localDirs.end() &&
+ rParams.mpExcludeDirs != NULL &&
+ rParams.mpExcludeDirs->IsExcluded(localPath))
+ {
+ // Not found -- report
+ printf("Local directory '%s' is excluded, but "
+ "store directory '%s' still exists.\n",
+ localPathDisplay.c_str(),
+ storePathDisplay.c_str());
+ rParams.mDifferences ++;
+ }
+ else if(local == localDirs.end())
{
// Not found -- report
printf("Local directory '%s' does not exist, "
@@ -1763,10 +1775,15 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
storePathDisplay.c_str());
rParams.mDifferences ++;
}
+ else if(rParams.mpExcludeDirs != NULL &&
+ rParams.mpExcludeDirs->IsExcluded(localPath))
+ {
+ // don't recurse into excluded directories
+ }
else
{
// Compare directory
- Compare(i->second->GetObjectID(), rStoreDir + "/" + i->first, rLocalDir + DIRECTORY_SEPARATOR + i->first, rParams);
+ Compare(i->second->GetObjectID(), rStoreDir + "/" + i->first, localPath, rParams);
// Remove from set so that we know it's been compared
localDirs.erase(local);
@@ -1786,15 +1803,15 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
const std::string& fileNameDisplay(*i);
#endif
- std::string localPath = rLocalDir +
- DIRECTORY_SEPARATOR + *i;
- std::string storePath = rStoreDir +
- "/" + *i;
+ std::string localPath(MakeFullPath
+ (rLocalDir, *i));
+ std::string localPathDisplay(MakeFullPath
+ (localDirDisplay, fileNameDisplay));
- std::string localPathDisplay = localDirDisplay +
- DIRECTORY_SEPARATOR + fileNameDisplay;
- std::string storePathDisplay = storeDirDisplay +
- "/" + fileNameDisplay;
+ std::string storePath
+ (rStoreDir + "/" + *i);
+ std::string storePathDisplay
+ (storeDirDisplay + "/" + fileNameDisplay);
// Should this be ignored (ie is excluded)?
if(rParams.mpExcludeDirs == 0 || !(rParams.mpExcludeDirs->IsExcluded(localPath)))