Repository navigation
Expand file tree
/
Copy pathgovernance.cpp
More file actions
58 lines (44 loc) · 1.89 KB
/
Copy pathgovernance.cpp
File metadata and controls
58 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "governance.hpp"
#include <set>
namespace dynamic_file_binder {
namespace {
bool IsLargeFileType(const std::filesystem::path& path)
{
static const std::set<std::string> largeExtensions = {".zip", ".7z", ".rar", ".iso", ".mp4", ".mkv", ".mov", ".avi", ".tar", ".gz"};
return largeExtensions.find(path.extension().string()) != largeExtensions.end();
}
} // namespace
GovernanceStack::GovernanceStack(GovernanceRules rules)
: rules_(rules)
{
}
GovernanceDecision GovernanceStack::Evaluate(const FileInfo& fileInfo, float systemLoadScore, bool forcePhysical) const
{
if (forcePhysical) {
if (!rules_.allowPhysicalCopies) {
ErrorManager::Instance().Report({
ErrorDomain::Governance,
ErrorSeverity::Warning,
"GOVERNANCE_PHYSICAL_DISABLED",
"Physische Kopien sind durch die Governance-Regeln deaktiviert.",
fileInfo.sourcePath,
});
return {GovernanceAction::Reject, "Physical copies disabled by governance rules"};
}
return {GovernanceAction::BindPhysical, "Physical copy forced by caller"};
}
if (systemLoadScore >= rules_.deferLoadThreshold) {
return {GovernanceAction::Defer, "System load is above defer threshold"};
}
if (!rules_.allowSymbolicLinks) {
return {GovernanceAction::BindPhysical, "Symbolic links are disabled by governance rules"};
}
if (systemLoadScore >= rules_.symbolicLoadThreshold) {
return {GovernanceAction::BindSymbolic, "Medium load prefers symbolic linking"};
}
if (fileInfo.fileSize >= rules_.symbolicSizeThresholdBytes || IsLargeFileType(fileInfo.sourcePath)) {
return {GovernanceAction::BindSymbolic, "Large files should be virtualized"};
}
return {GovernanceAction::BindPhysical, "Low load and no symbolic preference matched"};
}
} // namespace dynamic_file_binder