mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
PERF: Use app relative virtual path for file monitoring
This is so that the IVirtualPathMonitor implementation can properly cache virtual paths in a single entry. This decreases the number of entries by one or two order of magnitude when complex solutions are loaded (i.e. modules with lot of references to other modules). --HG-- branch : 1.x extra : transplant_source : %11%21n%FA%5Dy%E9%83%E3%86%86%D0%8Ba%FF%98%5C%8D/%22
This commit is contained in:
@@ -76,8 +76,9 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
foreach (var path in GetDependencies(projectPath)) {
|
||||
Logger.Information("Monitoring virtual path \"{0}\"", path);
|
||||
|
||||
monitor(_virtualPathMonitor.WhenPathChanges(path));
|
||||
_reloadWorkaround.Monitor(_virtualPathMonitor.WhenPathChanges(path));
|
||||
var token = _virtualPathMonitor.WhenPathChanges(path);
|
||||
monitor(token);
|
||||
_reloadWorkaround.Monitor(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +183,7 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
}
|
||||
|
||||
protected IEnumerable<string> GetDependencies(string projectPath) {
|
||||
HashSet<string> dependencies = new HashSet<string> { projectPath };
|
||||
var dependencies = new HashSet<string> { projectPath };
|
||||
|
||||
AddDependencies(projectPath, dependencies);
|
||||
|
||||
@@ -205,6 +206,18 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
? _virtualPathProvider.GetProjectReferenceVirtualPath(projectPath, referenceDescriptor.SimpleName, referenceDescriptor.Path)
|
||||
: _virtualPathProvider.Combine(basePath, referenceDescriptor.Path);
|
||||
|
||||
// Normalize the virtual path (avoid ".." in the path name)
|
||||
if (!string.IsNullOrEmpty(path)) {
|
||||
try {
|
||||
path = _virtualPathProvider.ToAppRelative(path);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// The initial path might have been invalid (e.g. path indicates a path outside the application root)
|
||||
Logger.Information(e, "Path '{0}' cannot be made app relative", path);
|
||||
path = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to reference the project / library file
|
||||
if (!string.IsNullOrEmpty(path) && !currentSet.Contains(path) && _virtualPathProvider.TryFileExists(path)) {
|
||||
currentSet.Add(path);
|
||||
|
||||
Reference in New Issue
Block a user