|
22 | 22 | ******************************************************************************/ |
23 | 23 | #include <sstream> |
24 | 24 | #include <algorithm> |
| 25 | +#include <functional> |
25 | 26 |
|
26 | 27 | #include "util/rstime.h" |
27 | 28 | #include "util/rsdir.h" |
@@ -669,26 +670,36 @@ bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& ind |
669 | 670 |
|
670 | 671 | // Do a complete recursive sweep of directory hierarchy and update cumulative size of directories |
671 | 672 |
|
672 | | -uint64_t InternalFileHierarchyStorage::recursUpdateCumulatedSize(const DirectoryStorage::EntryIndex& dir_index) |
| 673 | +uint64_t InternalFileHierarchyStorage::recursUpdateCumulatedSize(const DirectoryStorage::EntryIndex& dir_index, std::function<uint64_t(const RsFileHash&)> get_uploads) |
673 | 674 | { |
674 | 675 | DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ; |
675 | 676 |
|
676 | 677 | uint64_t local_cumulative_size = 0; |
677 | 678 | uint32_t local_cumulative_files = 0; |
| 679 | + uint64_t local_cumulative_uploads = 0; |
678 | 680 |
|
679 | 681 | for(uint32_t i=0;i<d.subfiles.size();++i) |
680 | 682 | if(mNodes[d.subfiles[i]]) { // normally not needed, but an extra-security |
681 | | - local_cumulative_size += static_cast<FileEntry*>(mNodes[d.subfiles[i]])->file_size; |
| 683 | + FileEntry *f = static_cast<FileEntry*>(mNodes[d.subfiles[i]]); |
| 684 | + local_cumulative_size += f->file_size; |
682 | 685 | local_cumulative_files++; |
| 686 | + |
| 687 | + if(get_uploads) |
| 688 | + local_cumulative_uploads += get_uploads(f->file_hash); |
683 | 689 | } |
684 | 690 |
|
685 | 691 | for(uint32_t i=0;i<d.subdirs.size();++i) { |
686 | | - local_cumulative_size += recursUpdateCumulatedSize(d.subdirs[i]); |
| 692 | + local_cumulative_size += recursUpdateCumulatedSize(d.subdirs[i], get_uploads); |
687 | 693 | local_cumulative_files += static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_cumulated_files; |
| 694 | + local_cumulative_uploads += static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_cumulated_uploads; |
688 | 695 | } |
689 | 696 |
|
690 | 697 | d.dir_cumulated_size = local_cumulative_size; |
691 | 698 | d.dir_cumulated_files = local_cumulative_files; |
| 699 | + d.dir_cumulated_uploads = local_cumulative_uploads; |
| 700 | + |
| 701 | + |
| 702 | + |
692 | 703 | return local_cumulative_size; |
693 | 704 | } |
694 | 705 | // 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. |
|
0 commit comments