-
-
Notifications
You must be signed in to change notification settings - Fork 182
Fix caching conflicts #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is interesting... |
How does it fix the caching conflicts?!! |
I am iterating on this PR, I got a bug report, so first trying to see if I can repro without changes but different OSes, then I will add a test, and then the fix. Using this PR as the way to run on the oses I don't have (macos). |
Fluid/DefaultTemplateCache.cs
Outdated
} | ||
|
||
public bool TryGetTemplate(IFileInfo fileInfo, out IFluidTemplate template) | ||
{ | ||
template = null; | ||
|
||
if (_cache.TryGetValue(fileInfo.Name, out var cachedTemplate)) | ||
if (_cache.TryGetValue(fileInfo.PhysicalPath, out var cachedTemplate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Physical path can be null for in-memory filesystems. I think this will break people unless you require this at some other level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the path relative to the file provider root instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic because IFileInfo
is very limited here:
//
// Summary:
// The name of the file or directory, not including any path.
string Name { get; }
//
// Summary:
// The path to the file, including the file name. Return null if the file is not
// directly accessible.
string? PhysicalPath { get; }
@@ -23,33 +22,31 @@ public TemplateCache() | |||
_cache = new(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); | |||
} | |||
|
|||
public bool TryGetTemplate(IFileInfo fileInfo, out IFluidTemplate template) | |||
public bool TryGetTemplate(string subpath, DateTimeOffset lastModified, out IFluidTemplate template) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.