[go: nahoru, domu]

Skip to content

Commit

Permalink
Feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhyxionNL committed Feb 10, 2023
1 parent d0877da commit bc08462
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/Smidge.Core/CompositeFiles/Compressor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
Expand All @@ -10,7 +10,9 @@ namespace Smidge.CompositeFiles
/// Performs byte compression
/// </summary>
public static class Compressor
{
{
public static async Task<Stream> CompressAsync(CompressionType type, Stream original) => await CompressAsync(type, CompressionLevel.Optimal, original);

public static async Task<Stream> CompressAsync(CompressionType type, CompressionLevel level, Stream original)
{
using (var ms = new MemoryStream())
Expand Down Expand Up @@ -50,4 +52,4 @@ public static async Task<Stream> CompressAsync(CompressionType type, Compression
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
internal static bool TryGetCachedCompositeFileResult(ISmidgeFileSystem fileSystem, string cacheBusterValue, string filesetKey, CompressionType type, string mime, out FileResult result, out DateTime lastWriteTime)
{
result = null;
lastWriteTime = DateTime.MinValue;

var cacheFile = fileSystem.CacheFileSystem.GetCachedCompositeFile(cacheBusterValue, type, filesetKey, out _);
if (cacheFile.Exists)
Expand All @@ -48,6 +47,7 @@ internal static bool TryGetCachedCompositeFileResult(ISmidgeFileSystem fileSyste
return true;
}

lastWriteTime = DateTime.Now;
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Smidge/Controllers/SmidgeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public async Task<IActionResult> Composite(
}
else
{
return File(cacheFile.CreateReadStream(), file.Mime);
}
return File(cacheFile.CreateReadStream(), file.Mime);
}
}

using (var bundleContext = new BundleContext(cacheBusterValue, file, cacheFilePath))
Expand All @@ -192,7 +192,7 @@ public async Task<IActionResult> Composite(

using (var resultStream = await GetCombinedStreamAsync(files, bundleContext))
{
var compressedStream = await Compressor.CompressAsync(file.Compression, CompressionLevel.Optimal, resultStream);
var compressedStream = await Compressor.CompressAsync(file.Compression, resultStream);

await CacheCompositeFileAsync(_fileSystem.CacheFileSystem, cacheFilePath, compressedStream);

Expand Down Expand Up @@ -241,4 +241,4 @@ private async Task<Stream> GetCombinedStreamAsync(IEnumerable<IFileInfo> files,
}
}
}
}
}

0 comments on commit bc08462

Please sign in to comment.