U4-626 - UmbracoFile.Save calls MapPath twice, causing problems with sites hosted on unc paths when uploading media

Created by Sebastiaan Janssen 19 Aug 2012, 14:55:05 Updated by Sebastiaan Janssen 28 Aug 2012, 09:27:32

Subtask of: U4-136

I'm hosting Umbraco 4.8.0 on Binero.se, and my site is hosted by several application pools, all reading their content from an unc path.

APPL_PHYSICAL_PATH = \atm.binero.net\content[id][id][domain]\public_html
(Swedish documentation at http://www.binero.se/support/faq/webbdatabas/vad-ar-den-absoluta-sokvagen )

UmbracoFile.Save calls IOHelper.MapPath twice for the path that's used to create the directory where the [in my case] media files should be stored.

input = ~/media/xxx first = \atm.binero.net\content...\public_html\media\xxx second = \atm.binero.net\content...\public_html\atm.binero.se\content...\public_html\media\xxx

The second resolve will create the folder atm.binero.net in public_html which also shows up in my ftp client. The solution/fix for me was to remove the second call to IOHelper.MapPath. I used Reflexil to do this, but I'll attempt to provide a handwritten diff. ;)

  • DirectoryInfo di = new DirectoryInfo(IO.IOHelper.MapPath(fullFilePath.Substring(0, fullFilePath.LastIndexOf(Path.DirectorySeparatorChar))));
  • DirectoryInfo di = new DirectoryInfo(fullFilePath.Substring(0, fullFilePath.LastIndexOf(Path.DirectorySeparatorChar)));

''Originally created on CodePlex by [sisve|http://www.codeplex.com/site/users/view/sisve]'' on 7/26/2012 6:16:50 PM [Codeplex ID: 30947 - Codeplex Votes: 4]

Imported comments

''Comment by [markuspeter|http://www.codeplex.com/site/users/view/markuspeter] on 8/8/2012 11:53:09 AM:'' The same method also throws an error when having /media as a virtual directory mapped to a local directory outside of the web site (http://our.umbraco.org/forum/getting-started/installing-umbraco/33702-Upload-media-to-virtual-directory-startIndex-cannot-be-larger-than-length-of-string ) This used to work ok with previous versions.

Comments

Sebastiaan Janssen 28 Aug 2012, 09:26:34

Due to the changes to the media uploader, this code is no longer in place so should not be a problem any more.


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.8.0, 4.9.0

Due in version: 4.9.0

Sprint:

Story Points:

Cycle: