diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/preview/PreviewContent.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/preview/PreviewContent.cs index 2499c1c817..44faec0868 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/preview/PreviewContent.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/preview/PreviewContent.cs @@ -99,7 +99,7 @@ namespace umbraco.presentation.preview //Inject preview xml parentId = document.Level == 1 ? -1 : document.ParentId; var previewXml = document.ToPreviewXml(XmlContent); - if (document.ContentEntity.Published == false + if (document.ContentEntity.Published == false && ApplicationContext.Current.Services.ContentService.HasPublishedVersion(document.Id)) previewXml.Attributes.Append(XmlContent.CreateAttribute("isDraft")); XmlContent = content.GetAddOrUpdateXmlNode(XmlContent, document.Id, document.Level, parentId, previewXml); @@ -187,13 +187,9 @@ namespace umbraco.presentation.preview private static void CleanPreviewDirectory(int userId, DirectoryInfo dir) { - foreach (FileInfo file in dir.GetFiles(userId + "_*.config")) - { - DeletePreviewFile(userId, file); - } // also delete any files accessed more than 10 minutes ago var now = DateTime.Now; - foreach (FileInfo file in dir.GetFiles("*.config")) + foreach (var file in dir.GetFiles("*.config")) { if ((now - file.LastAccessTime).TotalMinutes > 10) DeletePreviewFile(userId, file); @@ -208,7 +204,11 @@ namespace umbraco.presentation.preview } catch (Exception ex) { - LogHelper.Error(string.Format("Couldn't delete preview set: {0} - User {1}", file.Name, userId), ex); + // for *some* reason deleting the file can fail, + // and it will work later on (long-lasting locks, etc), + // so just ignore the exception + + //LogHelper.Error(string.Format("Couldn't delete preview set: {0} - User {1}", file.Name, userId), ex); } }