diff options
| author | Stefan Boberg <[email protected]> | 2022-01-28 13:30:07 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-01-28 13:30:07 +0100 |
| commit | 31a2c8a818a904969f17d24dbec7c50dcd688638 (patch) | |
| tree | 3c1e58e1cc24c86134acfd40c8bf12f22b4f16d6 /zenutil/cache/cachepolicy.cpp | |
| parent | Structured cache PUTs now preserve content type for binary and compressed binary (diff) | |
| parent | Compile fix (diff) | |
| download | zen-31a2c8a818a904969f17d24dbec7c50dcd688638.tar.xz zen-31a2c8a818a904969f17d24dbec7c50dcd688638.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenutil/cache/cachepolicy.cpp')
| -rw-r--r-- | zenutil/cache/cachepolicy.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/zenutil/cache/cachepolicy.cpp b/zenutil/cache/cachepolicy.cpp index ba345485a..3bf7a0c67 100644 --- a/zenutil/cache/cachepolicy.cpp +++ b/zenutil/cache/cachepolicy.cpp @@ -4,6 +4,7 @@ #include <zencore/compactbinary.h> #include <zencore/compactbinarybuilder.h> +#include <zencore/enumflags.h> #include <zencore/string.h> #include <algorithm> @@ -206,6 +207,25 @@ CacheRecordPolicy::Load(CbObjectView Object, CachePolicy DefaultPolicy) return Builder.Build(); } +CacheRecordPolicy +CacheRecordPolicy::ConvertToUpstream() const +{ + auto DownstreamToUpstream = [](CachePolicy P) { + // Remote|Local -> Set Remote + // Delete Skip Flags + // Maintain Remaining Flags + return (EnumHasAllFlags(P, CachePolicy::QueryRemote) ? CachePolicy::QueryLocal : CachePolicy::None) | + (EnumHasAllFlags(P, CachePolicy::StoreRemote) ? CachePolicy::StoreLocal : CachePolicy::None) | + (P & ~(CachePolicy::SkipData | CachePolicy::SkipMeta)); + }; + CacheRecordPolicyBuilder Builder(DownstreamToUpstream(GetDefaultValuePolicy())); + for (const CacheValuePolicy& ValuePolicy : GetValuePolicies()) + { + Builder.AddValuePolicy(ValuePolicy.Id, DownstreamToUpstream(ValuePolicy.Policy)); + } + return Builder.Build(); +} + void CacheRecordPolicyBuilder::AddValuePolicy(const CacheValuePolicy& Policy) { |