ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
771 stars 114 forks source link

EnableDiskCache = false still save to disk #90

Open DavidJoyal opened 5 years ago

DavidJoyal commented 5 years ago

When I tried to disabled the cache to disk, by adding this to my appsettings.json "webOptimizer": { "enableDiskCache": false } the class AssetResponse still try to save it on the disk.

I think the error come from the class AssetBuilder in the function BuildAsync on the line: await _assetResponseCache.AddAsync(asset.Route, cacheKey, response).ConfigureAwait(false);

I think it should be if (options.EnableDiskCache == true) { await _assetResponseCache.AddAsync(asset.Route, cacheKey, response).ConfigureAwait(false); }

Any chance you can add this line or correct this bug in an other way?

In my case, the css and js return a 500 error because my user does not have the right to create the folder and the file

Here is the error (I removed the path on my disk) System.UnauthorizedAccessException: Access to the path '**custom path**' is denied. at System.IO.FileSystem.CreateDirectory(String fullPath) at System.IO.Directory.CreateDirectory(String path) at WebOptimizer.AssetResponseStore.AddAsync(String bucket, String cachekey, AssetResponse assetResponse) at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options) at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext]

DavidJoyal commented 5 years ago

Any chance you correct this @madskristensen ?

Also pinged @hellfirehd because I think he was the one who added this fonctionality?

hellfirehd commented 5 years ago

That looks reasonable. Send a pull request and it will probably get accepted sooner. I’m running off a fork because I think this project is abandoned/dead.

DavidJoyal commented 5 years ago

Alright, I just did that. I hope I did it right

Thank you

peterbomers commented 5 years ago

Is it possible to approve this merge? We're using the Azure run from package feature, that creates a readonly wwwroot content directory. All the first call to WebOptimizer fail (disk caching is disabled) because it's not allowed to create the directory.

slaneyrw commented 4 years ago

Can someone please approve this merge ?

madskristensen commented 4 years ago

Done

slaneyrw commented 4 years ago

Is there going to be a new release with this fix... the latest public package still contains the bug.

... or do I need to fork this project coz it's dead