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