added parameter to disallow hashing files which time is in the future (as they severely perturbate the synchronisation process)

This commit is contained in:
csoler 2016-11-16 21:49:27 +01:00
parent 6272856b5e
commit ba78007cf1
3 changed files with 12 additions and 4 deletions

View File

@ -141,7 +141,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
// make sure list of subfiles is the same // make sure list of subfiles is the same
// request all hashes to the hashcache // request all hashes to the hashcache
librs::util::FolderIterator dirIt(cumulated_path,false); librs::util::FolderIterator dirIt(cumulated_path,false,false); // disallow symbolic links and files from the future.
time_t dir_local_mod_time ; time_t dir_local_mod_time ;
if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time)) if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time))

View File

@ -16,8 +16,8 @@
namespace librs { namespace util { namespace librs { namespace util {
FolderIterator::FolderIterator(const std::string& folderName,bool allow_symlinks) FolderIterator::FolderIterator(const std::string& folderName, bool allow_symlinks, bool allow_files_from_the_future)
: mFolderName(folderName),mAllowSymLinks(allow_symlinks) : mFolderName(folderName),mAllowSymLinks(allow_symlinks),mAllowFilesFromTheFuture(allow_files_from_the_future)
{ {
is_open = false ; is_open = false ;
validity = false ; validity = false ;
@ -141,6 +141,13 @@ bool FolderIterator::updateFileInfo(bool& should_skip)
{ {
mFileModTime = buf.st_mtime ; mFileModTime = buf.st_mtime ;
if(buf.st_mtime > time(NULL) && !mAllowFilesFromTheFuture)
{
std::cerr << "(II) skipping file with modification time in the future: " << mFullPath << std::endl;
should_skip = true ;
return true ;
}
if (S_ISDIR(buf.st_mode)) if (S_ISDIR(buf.st_mode))
{ {
#ifdef DEBUG_FOLDER_ITERATOR #ifdef DEBUG_FOLDER_ITERATOR

View File

@ -22,7 +22,7 @@ namespace librs { namespace util {
class FolderIterator class FolderIterator
{ {
public: public:
FolderIterator(const std::string& folderName,bool allow_symlinks); FolderIterator(const std::string& folderName,bool allow_symlinks,bool allow_files_from_the_future = true);
~FolderIterator(); ~FolderIterator();
enum { TYPE_UNKNOWN = 0x00, enum { TYPE_UNKNOWN = 0x00,
@ -69,6 +69,7 @@ private:
std::string mFullPath ; std::string mFullPath ;
std::string mFolderName ; std::string mFolderName ;
bool mAllowSymLinks; bool mAllowSymLinks;
bool mAllowFilesFromTheFuture;
}; };