mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 09:42:29 +08:00
Optimizing FileSystemStorageProvider.ListProfiles
This commit is contained in:
@@ -271,17 +271,18 @@ namespace Orchard.FileSystems.Media {
|
|||||||
/// <param name="path">The relative path to the file to be deleted.</param>
|
/// <param name="path">The relative path to the file to be deleted.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IEnumerable<FileInfo> ListProfiles(string path) {
|
private IEnumerable<FileInfo> ListProfiles(string path) {
|
||||||
|
var directoryInfo = new DirectoryInfo(MapStorage("_Profiles"));
|
||||||
|
|
||||||
|
if (!directoryInfo.Exists) return Enumerable.Empty<FileInfo>();
|
||||||
|
|
||||||
var filenameWithExtension = Path.GetFileName(path) ?? "";
|
var filenameWithExtension = Path.GetFileName(path) ?? "";
|
||||||
var urlpath = GetPublicUrl(path);
|
var urlpath = GetPublicUrl(path);
|
||||||
var fileLocation = urlpath.Substring(0, urlpath.Length - filenameWithExtension.Length);
|
var fileLocation = urlpath.Substring(0, urlpath.Length - filenameWithExtension.Length);
|
||||||
var hashpath = fileLocation.GetHashCode().ToString("x").ToLowerInvariant();
|
var hashpath = fileLocation.GetHashCode().ToString("x").ToLowerInvariant();
|
||||||
DirectoryInfo directoryInfo = new DirectoryInfo(MapStorage("_Profiles"));
|
|
||||||
|
|
||||||
return directoryInfo.Exists ?
|
return directoryInfo
|
||||||
directoryInfo
|
.GetFiles(filenameWithExtension, SearchOption.AllDirectories)
|
||||||
.GetFiles(filenameWithExtension, SearchOption.AllDirectories)
|
.Where(x => x.Directory.Name.Equals(hashpath));
|
||||||
.Where(x => x.Directory.Name.Equals(hashpath)) :
|
|
||||||
Enumerable.Empty<FileInfo>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user