Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/file_sharing/dir_hierarchy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,21 @@ uint64_t InternalFileHierarchyStorage::recursUpdateCumulatedSize(const Directory
DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ;

uint64_t local_cumulative_size = 0;
uint32_t local_cumulative_files = 0;

for(uint32_t i=0;i<d.subfiles.size();++i)
if(mNodes[d.subfiles[i]]) // normally not needed, but an extra-security
if(mNodes[d.subfiles[i]]) { // normally not needed, but an extra-security
local_cumulative_size += static_cast<FileEntry*>(mNodes[d.subfiles[i]])->file_size;
local_cumulative_files++;
}

for(uint32_t i=0;i<d.subdirs.size();++i)
for(uint32_t i=0;i<d.subdirs.size();++i) {
local_cumulative_size += recursUpdateCumulatedSize(d.subdirs[i]);
local_cumulative_files += static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_cumulated_files;
}

d.dir_cumulated_size = local_cumulative_size;
d.dir_cumulated_files = local_cumulative_files;
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.
Expand Down
3 changes: 2 additions & 1 deletion src/file_sharing/dir_hierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class InternalFileHierarchyStorage
class DirEntry: public FileStorageNode
{
public:
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) {}
explicit DirEntry(const std::string& name) : dir_name(name), dir_cumulated_size(0), dir_cumulated_files(0), dir_modtime(0),dir_most_recent_time(0),dir_update_time(0) {}
virtual ~DirEntry() {}

virtual uint32_t type() const { return FileStorageNode::TYPE_DIR ; }
Expand All @@ -73,6 +73,7 @@ class InternalFileHierarchyStorage
std::string dir_parent_path ;
RsFileHash dir_hash ;
uint64_t dir_cumulated_size;
uint32_t dir_cumulated_files;

std::vector<DirectoryStorage::EntryIndex> subdirs ;
std::vector<DirectoryStorage::EntryIndex> subfiles ;
Expand Down
1 change: 1 addition & 0 deletions src/file_sharing/directory_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
d.type = DIR_TYPE_DIR;
d.hash.clear() ;
d.size = dir_entry->dir_cumulated_size;//dir_entry->subdirs.size() + dir_entry->subfiles.size();
d.count = dir_entry->dir_cumulated_files;
d.max_mtime = dir_entry->dir_most_recent_time ;
d.mtime = dir_entry->dir_modtime ;
d.name = dir_entry->dir_name;
Expand Down
4 changes: 3 additions & 1 deletion src/retroshare/rstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ struct DirStub : RsSerializable
struct DirDetails : RsSerializable
{
DirDetails() : parent(nullptr), prow(0), ref(nullptr),
type(DIR_TYPE_UNKNOWN), size(0), mtime(0), max_mtime(0) {}
type(DIR_TYPE_UNKNOWN), size(0), mtime(0), max_mtime(0), count(0) {}


/* G10h4ck do we still need to keep this as void* instead of uint64_t for
Expand All @@ -303,6 +303,7 @@ struct DirDetails : RsSerializable
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.
uint32_t count; // cumulative number of files in the directory hierarchy.

std::vector<DirStub> children;
std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory
Expand Down Expand Up @@ -332,6 +333,7 @@ struct DirDetails : RsSerializable
RS_SERIAL_PROCESS(mtime);
RS_SERIAL_PROCESS(flags);
RS_SERIAL_PROCESS(max_mtime);
RS_SERIAL_PROCESS(count);
RS_SERIAL_PROCESS(children);
RS_SERIAL_PROCESS(parent_groups);
}
Expand Down
Loading