diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index bba2ff35e..30b90052e 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -141,7 +141,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p // make sure list of subfiles is the same // 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 ; if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time)) diff --git a/libretroshare/src/util/folderiterator.cc b/libretroshare/src/util/folderiterator.cc index 5846ded20..23d6cf93b 100644 --- a/libretroshare/src/util/folderiterator.cc +++ b/libretroshare/src/util/folderiterator.cc @@ -16,8 +16,8 @@ namespace librs { namespace util { -FolderIterator::FolderIterator(const std::string& folderName,bool allow_symlinks) - : mFolderName(folderName),mAllowSymLinks(allow_symlinks) +FolderIterator::FolderIterator(const std::string& folderName, bool allow_symlinks, bool allow_files_from_the_future) + : mFolderName(folderName),mAllowSymLinks(allow_symlinks),mAllowFilesFromTheFuture(allow_files_from_the_future) { is_open = false ; validity = false ; @@ -141,6 +141,13 @@ bool FolderIterator::updateFileInfo(bool& should_skip) { 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)) { #ifdef DEBUG_FOLDER_ITERATOR diff --git a/libretroshare/src/util/folderiterator.h b/libretroshare/src/util/folderiterator.h index 3ff4b31e1..79a011ace 100644 --- a/libretroshare/src/util/folderiterator.h +++ b/libretroshare/src/util/folderiterator.h @@ -22,7 +22,7 @@ namespace librs { namespace util { class FolderIterator { 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(); enum { TYPE_UNKNOWN = 0x00, @@ -69,6 +69,7 @@ private: std::string mFullPath ; std::string mFolderName ; bool mAllowSymLinks; + bool mAllowFilesFromTheFuture; };