HotcakesCommerce / hotcakes-commerce-core

The core of the e-commerce part of the overall solution. This is an ecommerce shopping cart solution built on top of the DNN (DotNetNuke) CMS. Anyone can do commerce online now!
https://mmmcommerce.com
MIT License
69 stars 55 forks source link

Hotcakes.Web.Images.ShrinkImageFileOnDisk temp files doesn't get deleted #320

Open Shaahkral opened 3 years ago

Shaahkral commented 3 years ago

Trying to use the software in environment having more than 100k products we got into the following issue. The problem is in the function public static void ShrinkImageFileOnDisk(string originalFile, string newFileName, int maxWidth, int maxHeight) { var tempFile = TempFiles.GetTemporaryFileInfo(); var settings = new ResizeSettings(maxWidth, maxHeight, FitMode.Max, null); ImageBuilder.Current.Build(originalFile, tempFile.FullName, settings); if (File.Exists(newFileName)) { File.SetAttributes(newFileName, FileAttributes.Normal); File.Delete(newFileName); } File.Copy(tempFile.FullName, newFileName); }

The tempFile is never got deleted which causes futher calls to ShrinkImageFileOnDisk to fail with exception: Method:Hotcakes.Web.TempFiles.GetTemporaryFileInfo StackTrace: Message: System.ArgumentException: Unable to create temporary file: {0}The file exists. at Hotcakes.Web.TempFiles.GetTemporaryFileInfo() at Hotcakes.Web.Images.ShrinkImageFileOnDisk(String originalFile, String newFileName, Int32 maxWidth, Int32 maxHeight) at Hotcakes.Commerce.Utilities.ImageProcessing.ShrinkImage(String originalFile, String outputDirectory, Int32 maxWidth, Int32 maxHeight)

Hotcakes.Web.TempFiles.GetTemporaryFileInfo() uses system Path.GetTempFileName, and MSDN clearly states: "The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files."

WillStrohl commented 3 years ago

What version of Hotcakes is this? I only ask because a more recent release does this for you on a scheduled basis.

Shaahkral commented 3 years ago

Ours is 3.2.1 Didn't check if scheduled clearance is present here, but it wouldn't solve the problem anyway, as sometimes we need to do a full update of all our products(given amount of the products we have, it breaks far before all products are processed).

On Thu, Oct 15, 2020 at 9:06 PM Will Strohl notifications@github.com wrote:

What version of Hotcakes is this? I only ask because a more recent release does this for you on a scheduled basis.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HotcakesCommerce/hotcakes-commerce-core/issues/320#issuecomment-709498632, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM2JKJ3VVZIDT2ZCUKGKSDSK423RANCNFSM4SSG5JPQ .

WillStrohl commented 3 years ago

How many products does your store have? At which point (approximately) does this appear to break in your instance?

Shaahkral commented 3 years ago

It's a multi-portal project,there are roughly 140k products in total. The actual point is hard to tell,as it depends on too many things,but anyway,judging by the MDSN doc,it should happen when up to 65535 calls are done to the function.

On Fri, Oct 16, 2020 at 8:29 PM Will Strohl notifications@github.com wrote:

How many products does your store have? At which point (approximately) does this appear to break in your instance?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HotcakesCommerce/hotcakes-commerce-core/issues/320#issuecomment-710273458, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM2JKM5XM3YOU6EBOTAGMLSLB7HLANCNFSM4SSG5JPQ .