| Directory: | cvmfs/ |
|---|---|
| File: | cvmfs/catalog_counters.cc |
| Date: | 2025-11-30 02:35:17 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 48 | 53 | 90.6% |
| Branches: | 12 | 14 | 85.7% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * This file is part of the CernVM File System. | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include "catalog_counters.h" | ||
| 6 | |||
| 7 | #include "directory_entry.h" | ||
| 8 | #include "util/exception.h" | ||
| 9 | |||
| 10 | namespace catalog { | ||
| 11 | |||
| 12 | 20830 | void DeltaCounters::ApplyDelta(const DirectoryEntry &dirent, const int delta) { | |
| 13 |
2/2✓ Branch 1 taken 14034 times.
✓ Branch 2 taken 6796 times.
|
20830 | if (dirent.IsRegular()) { |
| 14 | 14034 | self.regular_files += delta; | |
| 15 | 14034 | self.file_size += delta * dirent.size(); | |
| 16 |
2/2✓ Branch 1 taken 490 times.
✓ Branch 2 taken 13544 times.
|
14034 | if (dirent.IsChunkedFile()) { |
| 17 | 490 | self.chunked_files += delta; | |
| 18 | 490 | self.chunked_file_size += delta * dirent.size(); | |
| 19 | } | ||
| 20 |
2/2✓ Branch 1 taken 138 times.
✓ Branch 2 taken 13896 times.
|
14034 | if (dirent.IsExternalFile()) { |
| 21 | 138 | self.externals += delta; | |
| 22 | 138 | self.external_file_size += delta * dirent.size(); | |
| 23 | } | ||
| 24 |
2/2✓ Branch 1 taken 454 times.
✓ Branch 2 taken 6342 times.
|
6796 | } else if (dirent.IsLink()) { |
| 25 | 454 | self.symlinks += delta; | |
| 26 |
2/2✓ Branch 1 taken 184 times.
✓ Branch 2 taken 6158 times.
|
6342 | } else if (dirent.IsSpecial()) { |
| 27 | 184 | self.specials += delta; | |
| 28 |
1/2✓ Branch 1 taken 6158 times.
✗ Branch 2 not taken.
|
6158 | } else if (dirent.IsDirectory()) { |
| 29 | 6158 | self.directories += delta; | |
| 30 | } else { | ||
| 31 | ✗ | PANIC(NULL); | |
| 32 | } | ||
| 33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20830 times.
|
20830 | if (dirent.HasXattrs()) { |
| 34 | ✗ | self.xattrs += delta; | |
| 35 | } | ||
| 36 | 20830 | } | |
| 37 | |||
| 38 | |||
| 39 | 1557 | void DeltaCounters::PopulateToParent(DeltaCounters *parent) const { | |
| 40 | 1557 | parent->subtree.Add(self); | |
| 41 | 1557 | parent->subtree.Add(subtree); | |
| 42 | 1557 | } | |
| 43 | |||
| 44 | ✗ | void DeltaCounters::RemoveFromSubtree(const DeltaCounters &child) { | |
| 45 | ✗ | subtree.Subtract(child.self); | |
| 46 | ✗ | subtree.Subtract(child.subtree); | |
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | 148 | void Counters::ApplyDelta(const DeltaCounters &delta) { | |
| 51 | 148 | self.Add(delta.self); | |
| 52 | 148 | subtree.Add(delta.subtree); | |
| 53 | 148 | } | |
| 54 | |||
| 55 | |||
| 56 | 46 | void Counters::AddAsSubtree(DeltaCounters *delta) const { | |
| 57 | 46 | delta->subtree.Add(self); | |
| 58 | 46 | delta->subtree.Add(subtree); | |
| 59 | 46 | } | |
| 60 | |||
| 61 | 148 | void Counters::MergeIntoParent(DeltaCounters *parent_delta) const { | |
| 62 | 148 | parent_delta->self.Add(self); | |
| 63 | 148 | parent_delta->subtree.Subtract(self); | |
| 64 | 148 | } | |
| 65 | |||
| 66 | |||
| 67 | 918 | Counters_t Counters::GetSelfEntries() const { | |
| 68 | 918 | return self.regular_files + self.symlinks + self.specials + self.directories; | |
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | 546 | Counters_t Counters::GetSubtreeEntries() const { | |
| 73 | 546 | return subtree.regular_files + subtree.symlinks + subtree.specials | |
| 74 | 546 | + subtree.directories; | |
| 75 | } | ||
| 76 | |||
| 77 | |||
| 78 | 454 | Counters_t Counters::GetAllEntries() const { | |
| 79 | 454 | return GetSelfEntries() + GetSubtreeEntries(); | |
| 80 | } | ||
| 81 | |||
| 82 | |||
| 83 | 331 | DeltaCounters Counters::Diff(const Counters &from, const Counters &to) { | |
| 84 | 331 | DeltaCounters result; | |
| 85 | 331 | result.self.Add(to.self); | |
| 86 | 331 | result.subtree.Add(to.subtree); | |
| 87 | 331 | result.self.Subtract(from.self); | |
| 88 | 331 | result.subtree.Subtract(from.subtree); | |
| 89 | 331 | return result; | |
| 90 | } | ||
| 91 | |||
| 92 | } // namespace catalog | ||
| 93 |