diff --git a/Directory.Build.props b/Directory.Build.props index fb93ffb2..e6e41428 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,7 +7,7 @@ VirtoCommerce - 6.20.0 + 6.21.0 $(VersionSuffix)-$(BuildNumber) diff --git a/VirtoCommerce.Storefront/Controllers/AssetController.cs b/VirtoCommerce.Storefront/Controllers/AssetController.cs index 46fb81cb..19ccbaa8 100644 --- a/VirtoCommerce.Storefront/Controllers/AssetController.cs +++ b/VirtoCommerce.Storefront/Controllers/AssetController.cs @@ -68,7 +68,7 @@ public async Task GetThemeAssets(string path) { var stream = await _themeEngine.GetAssetStreamAsync(path); return stream != null - ? File(stream, MimeTypes.GetMimeType(path)) + ? File(stream, MimeTypes.GetMimeType(path), true) : HandleStaticFiles(path); } diff --git a/VirtoCommerce.Storefront/Domain/ContentBlobProviders/FileSystemContentBlobProvider.cs b/VirtoCommerce.Storefront/Domain/ContentBlobProviders/FileSystemContentBlobProvider.cs index e0702d07..98c0bcea 100644 --- a/VirtoCommerce.Storefront/Domain/ContentBlobProviders/FileSystemContentBlobProvider.cs +++ b/VirtoCommerce.Storefront/Domain/ContentBlobProviders/FileSystemContentBlobProvider.cs @@ -2,9 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading; using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.FileProviders.Physical; +using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using VirtoCommerce.Storefront.Model.Caching; @@ -18,8 +17,7 @@ public class FileSystemContentBlobProvider : IContentBlobProvider { private readonly FileSystemBlobContentOptions _options; private readonly IStorefrontMemoryCache _memoryCache; - // Keep links to file watchers to prevent GC to collect it - private readonly PhysicalFilesWatcher _fileSystemWatcher; + private readonly PhysicalFileProvider _physicalFileProvider; public FileSystemContentBlobProvider(IOptions options, IStorefrontMemoryCache memoryCache) { @@ -30,7 +28,7 @@ public FileSystemContentBlobProvider(IOptions opti { //It is very important to have rootPath with leading slash '\' without this any changes won't reflected var rootPath = _options.Path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; - _fileSystemWatcher = new PhysicalFilesWatcher(rootPath, new FileSystemWatcher(rootPath), false); + _physicalFileProvider = new PhysicalFileProvider(rootPath); } } #region IContentBlobProvider Members @@ -118,19 +116,12 @@ public virtual IEnumerable Search(string path, string searchPattern, boo public virtual IChangeToken Watch(string path) { - if (_fileSystemWatcher != null) + if (_physicalFileProvider == null) { - // Absolute paths not permitted for watcher, need to convert it to relative - if (Path.IsPathRooted(path)) - { - path = GetRelativePath(path).TrimStart('/'); - } - return _fileSystemWatcher.CreateFileChangeToken(path); - } - else - { - return new CancellationChangeToken(new CancellationToken()); + return NullChangeToken.Singleton; } + + return _physicalFileProvider.Watch(path); } #endregion