diff options
Diffstat (limited to 'bin/bbackupquery/BackupQueries.cpp')
-rw-r--r-- | bin/bbackupquery/BackupQueries.cpp | 85 |
1 files changed, 74 insertions, 11 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 687dcb05..f799ab43 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -212,7 +212,7 @@ void BackupQueries::DoCommand(const char *Command, bool isFromCommandLine) { { "quit", "" }, { "exit", "" }, - { "list", "rodIFtTsh", }, + { "list", "rodIFtTash", }, { "pwd", "" }, { "cd", "od" }, { "lcd", "" }, @@ -397,6 +397,7 @@ void BackupQueries::CommandList(const std::vector<std::string> &args, const bool #define LIST_OPTION_NOFLAGS 'F' #define LIST_OPTION_TIMES_LOCAL 't' #define LIST_OPTION_TIMES_UTC 'T' + #define LIST_OPTION_TIMES_ATTRIBS 'a' #define LIST_OPTION_SIZEINBLOCKS 's' #define LIST_OPTION_DISPLAY_HASH 'h' @@ -435,6 +436,52 @@ void BackupQueries::CommandList(const std::vector<std::string> &args, const bool List(rootDir, listRoot, opts, true /* first level to list */); } +static std::string GetTimeString(BackupStoreDirectory::Entry& en, + bool useLocalTime, bool showAttrModificationTimes) +{ + std::ostringstream out; + box_time_t originalTime, newAttributesTime; + + // there is no attribute modification time in the directory + // entry, unfortunately, so we can't display it. + originalTime = en.GetModificationTime(); + out << BoxTimeToISO8601String(originalTime, useLocalTime); + + if(en.HasAttributes()) + { + const StreamableMemBlock &storeAttr(en.GetAttributes()); + BackupClientFileAttributes attr(storeAttr); + + box_time_t NewModificationTime, NewAttrModificationTime; + attr.GetModificationTimes(&NewModificationTime, + &NewAttrModificationTime); + + if (showAttrModificationTimes) + { + newAttributesTime = NewAttrModificationTime; + } + else + { + newAttributesTime = NewModificationTime; + } + + if (newAttributesTime == originalTime) + { + out << "*"; + } + else + { + out << "~" << BoxTimeToISO8601String(newAttributesTime, + useLocalTime); + } + } + else + { + out << " "; + } + + return out.str(); +} // -------------------------------------------------------------------------- // @@ -534,17 +581,15 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool if(opts[LIST_OPTION_TIMES_UTC]) { // Show UTC times... - std::string time = BoxTimeToISO8601String( - en->GetModificationTime(), false); - printf("%s ", time.c_str()); + printf("%s ", GetTimeString(*en, false, + opts[LIST_OPTION_TIMES_ATTRIBS]).c_str()); } if(opts[LIST_OPTION_TIMES_LOCAL]) { // Show local times... - std::string time = BoxTimeToISO8601String( - en->GetModificationTime(), true); - printf("%s ", time.c_str()); + printf("%s ", GetTimeString(*en, true, + opts[LIST_OPTION_TIMES_ATTRIBS]).c_str()); } if(opts[LIST_OPTION_DISPLAY_HASH]) @@ -1544,13 +1589,31 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, continue; } + std::string localDirPath(MakeFullPath(rLocalDir, + localDirEn->d_name)); + std::string storeDirPath(rStoreDir + "/" + + localDirEn->d_name); + #ifndef HAVE_VALID_DIRENT_D_TYPE - std::string fn(MakeFullPath - (rLocalDir, localDirEn->d_name)); EMU_STRUCT_STAT st; - if(EMU_LSTAT(fn.c_str(), &st) != 0) + if(EMU_LSTAT(localDirPath.c_str(), &st) != 0) { - THROW_EXCEPTION(CommonException, OSFileError) + // Check whether dir is excluded before trying + // to stat it, to fix problems with .gvfs + // directories that are not readable by root + // causing compare to crash: + // http://lists.boxbackup.org/pipermail/boxbackup/2010-January/000013.html + if(rParams.IsExcludedDir(localDirPath)) + { + rParams.NotifyExcludedDir(localDirPath, + storeDirPath); + continue; + } + else + { + THROW_EXCEPTION_MESSAGE(CommonException, + OSFileError, localDirPath); + } } // Entry -- file or dir? |