Browse Source

Fixed cache bug.

Former-commit-id: 3ec039a00e918e4c03a21a21d2b5e48e375bf916
af/merge-core
JimBobSquarePants 13 years ago
parent
commit
a1e6ffd99e
  1. 27
      src/ImageProcessor.Web/Caching/DiskCache.cs
  2. 4
      src/ImageProcessor.Web/Properties/AssemblyInfo.cs
  3. 1
      src/Nuget/ImageProcessor.Web.2.2.0.1.nupkg.REMOVED.git-id
  4. 43
      src/Nuget/ImageProcessor.Web.2.2.0.1.nuspec
  5. 66
      src/Test/Test/Web.config

27
src/ImageProcessor.Web/Caching/DiskCache.cs

@ -283,7 +283,7 @@ namespace ImageProcessor.Web.Caching
{
// Check to see if the last write time is different of whether the
// cached image is set to expire or if the max age is different.
if (imageFileInfo.LastWriteTimeUtc != cachedImage.LastWriteTimeUtc
if (!this.RoughDateTimeCompare(imageFileInfo.LastWriteTimeUtc, cachedImage.LastWriteTimeUtc)
|| cachedImage.ExpiresUtc < DateTime.UtcNow.AddDays(-MaxFileCachedDuration)
|| cachedImage.MaxAge != MaxFileCachedDuration)
{
@ -461,6 +461,31 @@ namespace ImageProcessor.Web.Caching
return match.Success ? match.Value : string.Empty;
}
/// <summary>
/// The rough date time compare.
/// </summary>
/// <param name="first">
/// The first.
/// </param>
/// <param name="second">
/// The second.
/// </param>
/// <returns>
/// The <see cref="bool"/> true if the DateTimes roughly compare; otherwise, false.
/// </returns>
private bool RoughDateTimeCompare(DateTime first, DateTime second)
{
var x = first.ToString(CultureInfo.InvariantCulture);
var y = second.ToString(CultureInfo.InvariantCulture);
if (first.ToString(CultureInfo.InvariantCulture) == second.ToString(CultureInfo.InvariantCulture))
{
return true;
}
return false;
}
#endregion
#endregion
}

4
src/ImageProcessor.Web/Properties/AssemblyInfo.cs

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.2.0.1")]
[assembly: AssemblyFileVersion("2.2.0.1")]

1
src/Nuget/ImageProcessor.Web.2.2.0.1.nupkg.REMOVED.git-id

@ -0,0 +1 @@
8a3fd4491298fec4626034f03e534caac7f22941

43
src/Nuget/ImageProcessor.Web.2.2.0.1.nuspec

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ImageProcessor.Web</id>
<version>2.2.0.1</version>
<title>ImageProcessor.Web</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://jimbobsquarepants.github.com/ImageProcessor/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ImageProcessor.Web adds a configurable HttpModule to your website which allows on-the-fly processing of image files. The module also comes with a file and browser based cache that can handle up to 12,960,000 images increasing your processing output and saving precious server memory.
Methods include; Resize, Rotate, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, and Transparency.
This package also requires Microsoft.Bcl.Async -pre on .NET 4.0 which will be added in the background on install if applicable.
If you use ImageProcessor please get in touch via my twitter @james_m_south
Feedback is always welcome.</description>
<summary>An extension to ImageProcessor that allows on-the-fly processing of image files in an ASP.NET website</summary>
<releaseNotes>Fixed cache bug which caused unneccessary processing of images.
If upgrading from &lt; 2.2.0.0 You will have to delete your cache if upgrading to this version as the database differs.</releaseNotes>
<copyright>James South</copyright>
<language>en-GB</language>
<tags>Image, Imaging, ASP, Performance, Processing, HttpModule, Cache, Resize, Rotate, Flip, Crop, Filter, Effects, Quality, Watermark, Alpha, Vignette, Saturation, Brightness, Contrast, Gif, Jpeg, Bitmap, Png, Fluent</tags>
<dependencies>
<dependency id="ImageProcessor" version="1.5.0.0" />
<dependency id="Csharp-Sqlite" version="3.7.7.1" />
</dependencies>
</metadata>
<files>
<file src="content\net40\web.config.transform" target="content\net40\web.config.transform" />
<file src="content\net45\web.config.transform" target="content\net45\web.config.transform" />
<file src="..\ImageProcessor.Web\bin\Release\ImageProcessor.Web.dll" target="lib\net40\ImageProcessor.Web.dll" />
<file src="lib\net40\System.Runtime.dll" target="lib\net40\System.Runtime.dll" />
<file src="lib\net40\System.Threading.Tasks.dll" target="lib\net40\System.Threading.Tasks.dll" />
<file src="..\ImageProcessor.Web\bin\Release\ImageProcessor.Web.dll" target="lib\net45\ImageProcessor.Web.dll" />
<file src="tools\net40\install.ps1" target="tools\net40\install.ps1" />
<file src="tools\net45\install.ps1" target="tools\net45\install.ps1" />
</files>
</package>

66
src/Test/Test/Web.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
@ -7,78 +7,78 @@
<!-- Configuration section-handler declaration area. -->
<configSections>
<sectionGroup name="imageProcessor">
<section name="security" requirePermission="false" type="ImageProcessor.Web.Config.ImageSecuritySection, ImageProcessor.Web" />
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Config.ImageProcessingSection, ImageProcessor.Web" />
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Config.ImageCacheSection, ImageProcessor.Web" />
<section name="security" requirePermission="false" type="ImageProcessor.Web.Config.ImageSecuritySection, ImageProcessor.Web"/>
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Config.ImageProcessingSection, ImageProcessor.Web"/>
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Config.ImageCacheSection, ImageProcessor.Web"/>
</sectionGroup>
</configSections>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.0">
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
<forms loginUrl="~/Account/LogOn" timeout="2880"/>
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="System.Web.Helpers"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
<httpModules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web" />
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
</httpModules>
<!--Set the trust level.-->
<!--<trust level="Medium"/>-->
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0" />
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0" />
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<imageProcessor>
<security allowRemoteDownloads="true" timeout="300000" maxBytes="524288" remotePrefix="/remote.axd">
<whiteList>
<add url="http://images.mymovies.net" />
<add url="http://images.mymovies.net"/>
</whiteList>
</security>
<cache virtualPath="~/cache" maxDays="56" />
<cache virtualPath="~/cache" maxDays="56"/>
<processing>
<plugins>
<plugin name="Resize">
<settings>
<setting key="MaxWidth" value="1024" />
<setting key="MaxHeight" value="768" />
<setting key="MaxWidth" value="1024"/>
<setting key="MaxHeight" value="768"/>
</settings>
</plugin>
</plugins>

Loading…
Cancel
Save