From fab4784e451cf34cc22f2e0469b4dfa852924807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 23 Sep 2019 17:19:01 +0300 Subject: [PATCH] Fix bundling problem. --- .../Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs | 6 +++--- .../Extensions/FileProviders/AbpFileInfoExtensions.cs | 6 ++++++ .../Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs | 1 + .../Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs | 8 +++++--- .../VirtualFileSystem/DynamicFileProvider_Tests.cs | 11 +++++------ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs index 35bf730d70..653794bda8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs @@ -139,11 +139,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling DynamicFileProvider.AddOrUpdate( new InMemoryFileInfo( - Encoding.UTF8.GetBytes(bundleResult.Content), "/wwwroot/" + bundleRelativePath, //TODO: get rid of wwwroot! + Encoding.UTF8.GetBytes(bundleResult.Content), fileName - ) - ); + ) + ); } protected virtual bool IsBundlingEnabled() diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs b/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs index 5bc9402655..7d3505d616 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem.Embedded; namespace Microsoft.Extensions.FileProviders @@ -68,6 +69,11 @@ namespace Microsoft.Extensions.FileProviders return embeddedFileInfo.VirtualPath; } + if (fileInfo is InMemoryFileInfo inMemoryFileInfo) + { + return inMemoryFileInfo.DynamicPath; + } + return fileInfo.PhysicalPath; } } diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs index f7dc42704a..8d9bae8540 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs @@ -5,6 +5,7 @@ namespace Volo.Abp.VirtualFileSystem public interface IDynamicFileProvider : IFileProvider { void AddOrUpdate(IFileInfo fileInfo); + bool Delete(string filePath); } } diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs index d9ab30763a..0f529832a0 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.VirtualFileSystem public long Length => _fileContent.Length; - public string PhysicalPath { get; } + public string PhysicalPath => null; public string Name { get; } @@ -20,9 +20,11 @@ namespace Volo.Abp.VirtualFileSystem private readonly byte[] _fileContent; - public InMemoryFileInfo(byte[] fileContent, string physicalPath, string name) + public string DynamicPath { get; } + + public InMemoryFileInfo(string dynamicPath, byte[] fileContent, string name) { - PhysicalPath = physicalPath; + DynamicPath = dynamicPath; Name = name; _fileContent = fileContent; LastModified = DateTimeOffset.Now; diff --git a/framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs b/framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs index e3ff516949..45aaa88fd4 100644 --- a/framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs +++ b/framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Primitives; using Shouldly; @@ -24,8 +23,8 @@ namespace Volo.Abp.VirtualFileSystem _dynamicFileProvider.AddOrUpdate( new InMemoryFileInfo( - fileContent.GetBytes(), "/my-files/test.txt", + fileContent.GetBytes(), "test.txt" ) ); @@ -42,8 +41,8 @@ namespace Volo.Abp.VirtualFileSystem _dynamicFileProvider.AddOrUpdate( new InMemoryFileInfo( - "Hello World".GetBytes(), "/my-files/test.txt", + "Hello World".GetBytes(), "test.txt" ) ); @@ -60,8 +59,8 @@ namespace Volo.Abp.VirtualFileSystem _dynamicFileProvider.AddOrUpdate( new InMemoryFileInfo( - "Hello World UPDATED".GetBytes(), "/my-files/test.txt", + "Hello World UPDATED".GetBytes(), "test.txt" ) ); @@ -74,8 +73,8 @@ namespace Volo.Abp.VirtualFileSystem _dynamicFileProvider.AddOrUpdate( new InMemoryFileInfo( - "Hello World UPDATED 2".GetBytes(), "/my-files/test.txt", + "Hello World UPDATED 2".GetBytes(), "test.txt" ) ); @@ -88,7 +87,7 @@ namespace Volo.Abp.VirtualFileSystem { public override void ConfigureServices(ServiceConfigurationContext context) { - + } } }