mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
Merge pull request #2161 from csoler/v0.6-BugFixing_5
V0.6 bug fixing 5
This commit is contained in:
commit
733b059571
18 changed files with 175 additions and 106 deletions
|
@ -638,6 +638,23 @@ bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& ind
|
|||
return true;
|
||||
}
|
||||
|
||||
// Do a complete recursive sweep of directory hierarchy and update cumulative size of directories
|
||||
|
||||
uint64_t InternalFileHierarchyStorage::recursUpdateCumulatedSize(const DirectoryStorage::EntryIndex& dir_index)
|
||||
{
|
||||
DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ;
|
||||
|
||||
uint64_t local_cumulative_size = 0;
|
||||
|
||||
for(uint32_t i=0;i<d.subfiles.size();++i)
|
||||
local_cumulative_size += static_cast<FileEntry*>(mNodes[d.subfiles[i]])->file_size;
|
||||
|
||||
for(uint32_t i=0;i<d.subdirs.size();++i)
|
||||
local_cumulative_size += recursUpdateCumulatedSize(d.subdirs[i]);
|
||||
|
||||
d.dir_cumulated_size = local_cumulative_size;
|
||||
return local_cumulative_size;
|
||||
}
|
||||
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
|
||||
|
||||
rstime_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present)
|
||||
|
@ -1199,6 +1216,8 @@ bool InternalFileHierarchyStorage::load(const std::string& fname)
|
|||
if(!check(err_str))
|
||||
std::cerr << "(EE) Error while loading file hierarchy " << fname << std::endl;
|
||||
|
||||
recursUpdateCumulatedSize(mRoot);
|
||||
|
||||
return true ;
|
||||
}
|
||||
catch(read_error& e)
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
class DirEntry: public FileStorageNode
|
||||
{
|
||||
public:
|
||||
explicit DirEntry(const std::string& name) : dir_name(name), dir_modtime(0),dir_most_recent_time(0),dir_update_time(0) {}
|
||||
explicit DirEntry(const std::string& name) : dir_name(name), dir_cumulated_size(0), dir_modtime(0),dir_most_recent_time(0),dir_update_time(0) {}
|
||||
virtual ~DirEntry() {}
|
||||
|
||||
virtual uint32_t type() const { return FileStorageNode::TYPE_DIR ; }
|
||||
|
@ -72,6 +72,7 @@ public:
|
|||
std::string dir_name ;
|
||||
std::string dir_parent_path ;
|
||||
RsFileHash dir_hash ;
|
||||
uint64_t dir_cumulated_size;
|
||||
|
||||
std::vector<DirectoryStorage::EntryIndex> subdirs ;
|
||||
std::vector<DirectoryStorage::EntryIndex> subfiles ;
|
||||
|
@ -108,6 +109,10 @@ public:
|
|||
|
||||
rstime_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present);
|
||||
|
||||
// Do a complete recursive sweep over sub-directories and files, and update the cumulative size.
|
||||
|
||||
uint64_t recursUpdateCumulatedSize(const DirectoryStorage::EntryIndex& dir_index);
|
||||
|
||||
// hash stuff
|
||||
|
||||
bool getDirHashFromIndex(const DirectoryStorage::EntryIndex& index,RsFileHash& hash) const ;
|
||||
|
|
|
@ -235,7 +235,7 @@ 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.size = dir_entry->dir_cumulated_size;//dir_entry->subdirs.size() + dir_entry->subfiles.size();
|
||||
d.max_mtime = dir_entry->dir_most_recent_time ;
|
||||
d.mtime = dir_entry->dir_modtime ;
|
||||
d.name = dir_entry->dir_name;
|
||||
|
@ -253,7 +253,7 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
|||
const InternalFileHierarchyStorage::FileEntry *file_entry = mFileHierarchy->getFileEntry(indx) ;
|
||||
|
||||
d.type = DIR_TYPE_FILE;
|
||||
d.count = file_entry->file_size;
|
||||
d.size = file_entry->file_size;
|
||||
d.max_mtime = file_entry->file_modtime ;
|
||||
d.name = file_entry->file_name;
|
||||
d.hash = file_entry->file_hash;
|
||||
|
@ -292,6 +292,8 @@ void DirectoryStorage::checkSave()
|
|||
|
||||
if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now)
|
||||
{
|
||||
mFileHierarchy->recursUpdateCumulatedSize(mFileHierarchy->mRoot);
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
locked_check();
|
||||
|
@ -585,7 +587,7 @@ bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo&
|
|||
info.path = d.path + "/" + d.name;
|
||||
info.fname = d.name;
|
||||
info.hash = d.hash;
|
||||
info.size = d.count;
|
||||
info.size = d.size;
|
||||
|
||||
// all this stuff below is not useful in this case.
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
|||
{
|
||||
some_files_not_ready = true ;
|
||||
|
||||
std::cerr << "(WW) file " << dirIt.file_fullpath() << " is probably being modified. Keeping it for later." << std::endl;
|
||||
std::cerr << "(WW) file " << dirIt.file_fullpath() << " is probably being written to. Keeping it for later." << std::endl;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -138,7 +138,7 @@ void RsFileTree::recurs_buildFileTree(
|
|||
{
|
||||
FileData f ;
|
||||
f.name = dd2.name ;
|
||||
f.size = dd2.count ;
|
||||
f.size = dd2.size ;
|
||||
f.hash = dd2.hash ;
|
||||
|
||||
ft.mDirs[index].subfiles.push_back(ft.mFiles.size()) ;
|
||||
|
@ -186,7 +186,7 @@ std::unique_ptr<RsFileTree> RsFileTree::fromDirDetails(
|
|||
if(dd.type == DIR_TYPE_FILE)
|
||||
{
|
||||
FileData fd;
|
||||
fd.name = dd.name; fd.hash = dd.hash; fd.size = dd.count;
|
||||
fd.name = dd.name; fd.hash = dd.hash; fd.size = dd.size;
|
||||
ft->mFiles.push_back(fd);
|
||||
ft->mTotalFiles = 1;
|
||||
ft->mTotalSize = fd.size;
|
||||
|
|
|
@ -1004,7 +1004,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn
|
|||
d.prow = 0;//fi-1 ;
|
||||
d.type = DIR_TYPE_PERSON;
|
||||
d.hash.clear() ;
|
||||
d.count = mExtraFilesCache.size();
|
||||
d.size = mExtraFilesCache.size();
|
||||
d.max_mtime = time(NULL);
|
||||
d.mtime = time(NULL);
|
||||
d.name = "[Extra List]";
|
||||
|
@ -1029,7 +1029,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn
|
|||
FileInfo& f(mExtraFilesCache[(int)e-1]) ;
|
||||
|
||||
d.hash = f.hash;
|
||||
d.count = f.size;
|
||||
d.size = f.size;
|
||||
d.max_mtime = 0; // this is irrelevant
|
||||
d.mtime = 0; // this is irrelevant
|
||||
d.name = f.path; // so that the UI shows the complete path, since the parent directory is not really a directory.
|
||||
|
@ -1116,7 +1116,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
d.children.push_back(stub);
|
||||
}
|
||||
|
||||
d.count = d.children.size();
|
||||
d.size = 0; // non documented
|
||||
|
||||
#ifdef DEBUG_FILE_HIERARCHY
|
||||
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
||||
|
|
|
@ -22,25 +22,40 @@
|
|||
|
||||
//
|
||||
// This class is responsible for
|
||||
// - maintaining a list of shared file hierarchies for each known friends
|
||||
// - talking to the GUI
|
||||
// - providing handles for the directory tree listing GUI
|
||||
// - providing search handles for FT
|
||||
// - keeping these lists up to date
|
||||
// - sending our own file list to friends depending on the defined access rights
|
||||
// - serving file search requests from other services such as file transfer
|
||||
// - maintaining a list of shared file hierarchies for each known friends
|
||||
// - talking to the GUI
|
||||
// - providing handles for the directory tree listing GUI
|
||||
// - providing search handles for FT
|
||||
// - keeping these lists up to date
|
||||
// - sending our own file list to friends depending on the defined access rights
|
||||
// - serving file search requests from other services such as file transfer
|
||||
//
|
||||
// p3FileList does the following micro-tasks:
|
||||
// - tick the watchers
|
||||
// - get incoming info from the service layer, which can be:
|
||||
// - directory content request => the directory content is shared to the friend
|
||||
// - directory content => the directory watcher is notified
|
||||
// - keep two queues of update requests:
|
||||
// - fast queue that is handled in highest priority. This one is used for e.g. updating while browsing.
|
||||
// - slow queue that is handled slowly. Used in background update of shared directories.
|
||||
// p3FileList does the following micro-tasks:
|
||||
// - tick the watchers
|
||||
// - get incoming info from the service layer, which can be:
|
||||
// - directory content request => the directory content is shared to the friend
|
||||
// - directory content => the directory watcher is notified
|
||||
// - keep two queues of update requests:
|
||||
// - fast queue that is handled in highest priority. This one is used for e.g. updating while browsing.
|
||||
// - slow queue that is handled slowly. Used in background update of shared directories.
|
||||
//
|
||||
// The file lists are not directry updated. A FileListWatcher class is responsible for this
|
||||
// in every case.
|
||||
// The list of local shared files is maintained by FileListWatcher.
|
||||
//
|
||||
// p3FileLists is organised as follows:
|
||||
//
|
||||
// p3FileDatabase
|
||||
// |
|
||||
// +---- HashStorage // Handles known hashes. Serves as a reference when new files are hashed.
|
||||
// |
|
||||
// +---- RemoteDirectoryStorage // Stores the list of shared files at friends
|
||||
// | |
|
||||
// | +---- InternalFileHierarchyStorage
|
||||
// |
|
||||
// +---- LocalDirectoryStorage // Stores the list of locally shared files
|
||||
// | |
|
||||
// | +---- InternalFileHierarchyStorage
|
||||
// |
|
||||
// +---- LocalDirectoryUpdater // Keeps the local lists up to date, by regularly crawling directories
|
||||
//
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -2283,7 +2283,7 @@ std::error_condition ftServer::exportFileLink(
|
|||
tDirDet.type = DIR_TYPE_FILE;
|
||||
tDirDet.name = fileName;
|
||||
tDirDet.hash = fileHash;
|
||||
tDirDet.count = fileSize;
|
||||
tDirDet.size = fileSize;
|
||||
|
||||
return dirDetailsToLink(link, tDirDet, fragSneak, baseUrl);
|
||||
}
|
||||
|
@ -2308,7 +2308,7 @@ std::error_condition ftServer::parseFilesLink(
|
|||
dt.name = *tUrl.getQueryV("name");
|
||||
try
|
||||
{
|
||||
dt.count = std::stoull(*tUrl.getQueryV("size"));
|
||||
dt.size = std::stoull(*tUrl.getQueryV("size"));
|
||||
std::unique_ptr<RsFileTree> ft;
|
||||
if( !dt.hash.isNull() &&
|
||||
(ft = RsFileTree::fromDirDetails(dt, true)) )
|
||||
|
|
|
@ -300,7 +300,7 @@ struct DirStub : RsSerializable
|
|||
struct DirDetails : RsSerializable
|
||||
{
|
||||
DirDetails() : parent(nullptr), prow(0), ref(nullptr),
|
||||
type(DIR_TYPE_UNKNOWN), count(0), mtime(0), max_mtime(0) {}
|
||||
type(DIR_TYPE_UNKNOWN), size(0), mtime(0), max_mtime(0) {}
|
||||
|
||||
|
||||
/* G10h4ck do we still need to keep this as void* instead of uint64_t for
|
||||
|
@ -318,7 +318,7 @@ struct DirDetails : RsSerializable
|
|||
std::string name;
|
||||
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;
|
||||
uint64_t size; // total size of directory, or size of the file.
|
||||
uint32_t mtime; // file/directory modification time, according to what the system reports
|
||||
FileStorageFlags flags;
|
||||
uint32_t max_mtime ; // maximum modification time of the whole hierarchy below.
|
||||
|
@ -347,7 +347,7 @@ struct DirDetails : RsSerializable
|
|||
RS_SERIAL_PROCESS(name);
|
||||
RS_SERIAL_PROCESS(hash);
|
||||
RS_SERIAL_PROCESS(path);
|
||||
RS_SERIAL_PROCESS(count);
|
||||
RS_SERIAL_PROCESS(size);
|
||||
RS_SERIAL_PROCESS(mtime);
|
||||
RS_SERIAL_PROCESS(flags);
|
||||
RS_SERIAL_PROCESS(max_mtime);
|
||||
|
|
|
@ -1984,7 +1984,7 @@ void RsTurtleStringSearchRequestItem::search(std::list<TurtleFileInfo>& result)
|
|||
|
||||
TurtleFileInfo i ;
|
||||
i.hash = it->hash ;
|
||||
i.size = it->count ;
|
||||
i.size = it->size ;
|
||||
i.name = it->name ;
|
||||
|
||||
result.push_back(i) ;
|
||||
|
@ -2022,7 +2022,7 @@ void RsTurtleRegExpSearchRequestItem::search(std::list<TurtleFileInfo>& result)
|
|||
}
|
||||
TurtleFileInfo i ;
|
||||
i.hash = it->hash ;
|
||||
i.size = it->count ;
|
||||
i.size = it->size ;
|
||||
i.name = it->name ;
|
||||
|
||||
result.push_back(i) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue