kamsar / Dianoga

An automatic image optimizer for the Sitecore media library.
Other
104 stars 45 forks source link

Fix Access to the path 'C:\Windows\TEMP\tmpXXXX.tmp' is denied. #18 #19

Closed patocl closed 7 years ago

patocl commented 7 years ago

Hi @kamsar

The steps to solve it:

Define the path of the temporary folder and grant read/write access to 
the Application Pool Identity User to avoid access and write errors.

If TempPath is empty or not defined, the GetTempPath function will be used, trying 
to get the temp folder in this order:

1. The path specified by the TMP environment variable
2. The path specified by the TEMP environment variable
3. The path specified by the USERPROFILE environment variable
4. The Windows directory

Examples:

The folder is already included in the project
<TempPath>/App_Data/Dianoga Tools/Temp</ TempPath>

Let Windows choose the temporary folder
<TempPath> </ TempPath>

I'm using Visual Studio, but I do not understand why tabs or spaces are replaced, even with the new .editorconfig settings. Please, don't get nervous.

I hope you like it!

patocl

kamsar commented 7 years ago

Visual Studio 2015 requires an extension to support .editorconfig:

https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig

VS2017 will natively support it. Editors like Sublime and Atom (and VS Code) already support it :)

patocl commented 7 years ago

nice, I will add then to my VS2015. Thanks

patocl commented 7 years ago

I did my best effort to format the fu code...

The Editorconfig is not working properly on VS2015, was reported a Bug and I'm tired trying fix it manually

I hope it be ok Cheers mate

kamsar commented 7 years ago

It looks great, thanks for spending the time to format it :)

kamsar commented 7 years ago

I'm going to modify it slightly to default to the previous temp path behavior by default. The reason the dll copying was introduced was that folks' deploy processes were attempting to read/delete the PngOptimizerDll.dll file. When it's loaded it becomes locked and errors out their deployment.

So to solve that, it was set to copy outside the webroot and load from there, where it being locked would not break deploys. Leaving it in dianoga tools/temp would unfortunately bring that bug back.

However the temp path does need to be configurable - for folks who want it to go elsewhere other than windows temp.

kamsar commented 7 years ago

This is released in Dianoga 3.0.3-beta01. Give it a shot.