mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
do not send un-hashed files to friends, and allow to re-send the directory content when all files are hashed
This commit is contained in:
parent
84341f26b3
commit
a75115585b
@ -583,13 +583,26 @@ time_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectorySto
|
||||
DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ;
|
||||
|
||||
time_t largest_modf_time = d.dir_modtime ;
|
||||
bool unfinished_files_present = false ;
|
||||
|
||||
for(uint32_t i=0;i<d.subfiles.size();++i)
|
||||
largest_modf_time = std::max(largest_modf_time,static_cast<FileEntry*>(mNodes[d.subfiles[i]])->file_modtime) ;
|
||||
{
|
||||
FileEntry *f = static_cast<FileEntry*>(mNodes[d.subfiles[i]]) ;
|
||||
|
||||
if(!f->file_hash.isNull())
|
||||
largest_modf_time = std::max(largest_modf_time, f->file_modtime) ; // only account for hashed files, since we never send unhashed files to friends.
|
||||
else
|
||||
unfinished_files_present = true ;
|
||||
}
|
||||
|
||||
for(uint32_t i=0;i<d.subdirs.size();++i)
|
||||
largest_modf_time = std::max(largest_modf_time,recursUpdateLastModfTime(d.subdirs[i])) ;
|
||||
|
||||
// now if some files are not hashed in this directory, reduce the recurs time by 1, so that the TS wil be updated when all hashes are ready.
|
||||
|
||||
if(unfinished_files_present && largest_modf_time > 0)
|
||||
largest_modf_time-- ;
|
||||
|
||||
d.dir_most_recent_time = largest_modf_time ;
|
||||
|
||||
return largest_modf_time ;
|
||||
|
@ -637,6 +637,17 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary
|
||||
std::cerr << " not pushing subdir " << hash << ", array position=" << i << " indx=" << dir->subdirs[i] << ": permission denied for this peer." << std::endl;
|
||||
#endif
|
||||
|
||||
// now count the files that do not have a null hash (meaning the hash has indeed been computed)
|
||||
|
||||
uint32_t allowed_subfiles = 0 ;
|
||||
|
||||
for(uint32_t i=0;i<dir->subfiles.size();++i)
|
||||
{
|
||||
const InternalFileHierarchyStorage::FileEntry *file = mFileHierarchy->getFileEntry(dir->subfiles[i]) ;
|
||||
if(file != NULL && !file->file_hash.isNull())
|
||||
allowed_subfiles++ ;
|
||||
}
|
||||
|
||||
unsigned char *section_data = NULL;
|
||||
uint32_t section_size = 0;
|
||||
uint32_t section_offset = 0;
|
||||
@ -655,7 +666,7 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary
|
||||
// serialise number of subdirs and number of subfiles
|
||||
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subdirs.size() )) return false ;
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)dir->subfiles.size() )) return false ;
|
||||
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_RAW_NUMBER,(uint32_t)allowed_subfiles )) return false ;
|
||||
|
||||
// serialise subdirs entry indexes
|
||||
|
||||
@ -672,9 +683,9 @@ bool LocalDirectoryStorage::serialiseDirEntry(const EntryIndex& indx,RsTlvBinary
|
||||
|
||||
const InternalFileHierarchyStorage::FileEntry *file = mFileHierarchy->getFileEntry(dir->subfiles[i]) ;
|
||||
|
||||
if(file == NULL)
|
||||
if(file == NULL || file->file_hash.isNull())
|
||||
{
|
||||
std::cerr << "(EE) cannot reach file entry " << dir->subfiles[i] << " to get/send file info." << std::endl;
|
||||
std::cerr << "(II) skipping unhashed or Null file entry " << dir->subfiles[i] << " to get/send file info." << std::endl;
|
||||
continue ;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user