Skip to content
Permalink
Browse files

Change BundleAsset to use manual glob search to avoid file scans

  • Loading branch information...
mythz committed Aug 28, 2019
1 parent 81d1b5b commit 648adb77167e7c5e7aada822efe747f9dc7678bb
Showing with 17 additions and 6 deletions.
  1. +17 −6 src/ServiceStack.Common/ViewUtils.cs
@@ -1259,13 +1259,24 @@ public static IEnumerable<IVirtualFile> GetBundleFiles(string filterName, IVirtu
if (existingBundleTag == null)
{
// use existing bundle if file with matching hash pattern is found
var fileSearchPath = outFilePath.Replace("[hash]", ".*");
var fileMatch = webVfs.GetAllMatchingFiles(fileSearchPath).FirstOrDefault();
if (fileMatch != null)
var outDirPath = outFilePath.LastLeftPart('/');
var outFileName = outFilePath.LastRightPart('/');
var outGlobFile = outFileName.Replace("[hash]", ".*");

// use glob search to avoid unnecessary file scans
var outDir = webVfs.GetDirectory(outDirPath);
if (outDir != null)
{
outHtmlTag = htmlTagFmt.Replace("{0}", "/" + fileMatch.VirtualPath);
memFs.WriteFile(outFilePath, outHtmlTag); //cache lookup
return outHtmlTag;
var outDirFiles = outDir.GetFiles();
foreach (var file in outDirFiles)
{
if (file.Name.Glob(outGlobFile))
{
outHtmlTag = htmlTagFmt.Replace("{0}", "/" + file.VirtualPath);
memFs.WriteFile(outFilePath, outHtmlTag); //cache lookup
return outHtmlTag;
}
}
}
}
else

0 comments on commit 648adb7

Please sign in to comment.
You can’t perform that action at this time.