From fdefe993b715a552802618760e0ea569ca91f5b7 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 22 Mar 2013 12:54:46 -0100 Subject: [PATCH] Fixes U4-1990 --- .../media/UmbracoMediaFactory.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/umbraco.cms/businesslogic/media/UmbracoMediaFactory.cs b/src/umbraco.cms/businesslogic/media/UmbracoMediaFactory.cs index 52ad7beb84..8f2d841fa5 100644 --- a/src/umbraco.cms/businesslogic/media/UmbracoMediaFactory.cs +++ b/src/umbraco.cms/businesslogic/media/UmbracoMediaFactory.cs @@ -85,15 +85,20 @@ namespace umbraco.cms.businesslogic.media if (childMedia.ContentType.Alias == MediaTypeAlias) { var prop = childMedia.getProperty("umbracoFile"); - if (prop != null) + if (prop != null && prop.Value != null) { - var destFilePath = FileSystem.GetRelativePath(prop.Id, fileName); - var destFileUrl = FileSystem.GetUrl(destFilePath); - - if (prop.Value.ToString() == destFileUrl) + int subfolderId; + var subfolder = prop.Value.ToString().Replace(FileSystem.GetUrl("/"), "").Split('/')[0]; + if (int.TryParse(subfolder, out subfolderId)) { - existingMedia = childMedia; - return true; + var destFilePath = FileSystem.GetRelativePath(subfolderId, fileName); + var destFileUrl = FileSystem.GetUrl(destFilePath); + + if (prop.Value.ToString() == destFileUrl) + { + existingMedia = childMedia; + return true; + } } } }