Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Shaahkral opened this issue Oct 15, 2020 · 4 comments
Open

Comments

@Shaahkral
Copy link

Shaahkral commented Oct 15, 2020

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
Copy link
Member

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

@Shaahkral
Copy link
Author

Shaahkral commented Oct 15, 2020 via email

@WillStrohl
Copy link
Member

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

@Shaahkral
Copy link
Author

Shaahkral commented Oct 19, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants