fixed problems with negative time shifts in DirDetails causing multiple GUI bugs in File Lists and Search

This commit is contained in:
csoler 2016-11-14 21:58:58 +01:00
parent d433713bd0
commit 8c8cc88503
9 changed files with 56 additions and 40 deletions

View file

@ -206,8 +206,6 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
RS_STACK_MUTEX(mDirStorageMtx) ;
d.children.clear() ;
time_t now = time(NULL) ;
uint32_t type = mFileHierarchy->getType(indx) ;
d.ref = (void*)(intptr_t)indx ;
@ -241,8 +239,8 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
d.type = DIR_TYPE_DIR;
d.hash.clear() ;
d.count = dir_entry->subdirs.size() + dir_entry->subfiles.size();
d.min_age = now - dir_entry->dir_most_recent_time ;
d.age = now - dir_entry->dir_modtime ;
d.max_mtime = dir_entry->dir_most_recent_time ;
d.mtime = dir_entry->dir_modtime ;
d.name = dir_entry->dir_name;
d.path = RsDirUtil::makePath(dir_entry->dir_parent_path, dir_entry->dir_name) ;
d.parent = (void*)(intptr_t)dir_entry->parent_index ;
@ -259,10 +257,10 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
d.type = DIR_TYPE_FILE;
d.count = file_entry->file_size;
d.min_age = now - file_entry->file_modtime ;
d.max_mtime = file_entry->file_modtime ;
d.name = file_entry->file_name;
d.hash = file_entry->file_hash;
d.age = now - file_entry->file_modtime;
d.mtime = file_entry->file_modtime;
d.parent = (void*)(intptr_t)file_entry->parent_index ;
const InternalFileHierarchyStorage::DirEntry *parent_dir_entry = mFileHierarchy->getDirEntry(file_entry->parent_index);

View file

@ -733,9 +733,9 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
d.name = "root";
d.hash.clear() ;
d.path = "";
d.age = 0;
d.mtime = 0;
d.flags.clear() ;
d.min_age = 0 ;
d.max_mtime = 0 ;
if(flags & RS_FILE_HINTS_LOCAL)
{
@ -1054,7 +1054,7 @@ int p3FileDatabase::filterResults(const std::list<EntryIndex>& firesults,std::li
P3FILELISTS_ERROR() << "(EE) Cannot get dir details for entry " << (void*)(intptr_t)*rit << std::endl;
continue ;
}
#ifdef P3FILELISTS_DEBUG
#ifdef DEBUG_P3FILELISTS
P3FILELISTS_DEBUG() << "Filtering candidate " << (void*)(intptr_t)(*rit) << ", flags=" << cdetails.flags << ", peer=" << peer_id ;
#endif
@ -1066,11 +1066,11 @@ int p3FileDatabase::filterResults(const std::list<EntryIndex>& firesults,std::li
{
cdetails.id.clear() ;
results.push_back(cdetails);
#ifdef P3FILELISTS_DEBUG
#ifdef DEBUG_P3FILELISTS
std::cerr << ": kept" << std::endl ;
#endif
}
#ifdef P3FILELISTS_DEBUG
#ifdef DEBUG_P3FILELISTS
else
std::cerr << ": discarded" << std::endl ;
#endif

View file

@ -239,9 +239,9 @@ public:
RsFileHash hash;
std::string path; // full path of the parent directory, when it is a file; full path of the dir otherwise.
uint64_t count;
uint32_t age;
uint32_t mtime; // file/directory modification time, according to what the system reports
FileStorageFlags flags;
uint32_t min_age ; // minimum age of files in this subtree
uint32_t max_mtime ; // maximum modification time of the whole hierarchy below.
std::vector<DirStub> children;
std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory

View file

@ -56,8 +56,8 @@ std::ostream &operator<<(std::ostream &out, const DirDetails& d)
std::cerr << " Hash : " << d.hash << std::endl;
std::cerr << " Path : " << d.path << std::endl;
std::cerr << " Count : " << d.count << std::endl;
std::cerr << " Age : " << d.age << std::endl;
std::cerr << " Min age : " << d.min_age << std::endl;
std::cerr << " Age : " << time(NULL) - (int)d.mtime << std::endl;
std::cerr << " Min age : " << time(NULL) - (int)d.max_mtime << std::endl;
std::cerr << " Flags : " << d.flags << std::endl;
std::cerr << " Parent groups : " ; for(std::list<RsNodeGroupId>::const_iterator it(d.parent_groups.begin());it!=d.parent_groups.end();++it) std::cerr << (*it) << " "; std::cerr << std::endl;
std::cerr << " Children : " ; for(uint32_t i=0;i<d.children.size();++i) std::cerr << (void*)(intptr_t)d.children[i].ref << " "; std::cerr << std::endl;