U4-4847 Refactor ContentService (#1266)

* U4-4748 - refactor Content-, Media- and MemberTypeRepository

* Cleanup Attempt

* Cleanup OperationStatus

* U4-4748 - refactor Content-, Media- and MemberTypeService

* U4-4748 - cleanup locking

* U4-4748 - refactor Content-, Media- and MemberRepository

* U4-4748 - refactor ContentService (in progress)

* U4-4748 - all unit of work must be completed

* U4-4748 - refactor locks, fix tests

* U4-4748 - deal with fixmes

* U4-4748 - lock table migration

* Update UmbracoVersion

* Fix AuthorizeUpgrade

* U4-4748 - cleanup+bugfix lock objects

* U4-4748 - bugfix

* updates a string interpolation
This commit is contained in:
Stephan
2016-05-18 10:55:19 +02:00
committed by Shannon Deminick
parent 12f4873c90
commit ddf38407d8
139 changed files with 7539 additions and 6981 deletions

View File

@@ -4,8 +4,10 @@ using System.Globalization;
using System.Reflection;
using System.IO;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Hosting;
using ICSharpCode.SharpZipLib.Zip;
using Umbraco.Core.Configuration;
@@ -306,7 +308,7 @@ namespace Umbraco.Core.IO
var debugFolder = Path.Combine(binFolder, "debug");
if (Directory.Exists(debugFolder))
return debugFolder;
#endif
#endif
var releaseFolder = Path.Combine(binFolder, "release");
if (Directory.Exists(releaseFolder))
return releaseFolder;
@@ -341,7 +343,7 @@ namespace Umbraco.Core.IO
public static void EnsurePathExists(string path)
{
var absolutePath = IOHelper.MapPath(path);
var absolutePath = MapPath(path);
if (Directory.Exists(absolutePath) == false)
Directory.CreateDirectory(absolutePath);
}
@@ -349,14 +351,58 @@ namespace Umbraco.Core.IO
public static void EnsureFileExists(string path, string contents)
{
var absolutePath = IOHelper.MapPath(path);
if (File.Exists(absolutePath) == false)
if (File.Exists(absolutePath)) return;
using (var writer = File.CreateText(absolutePath))
{
using (var writer = File.CreateText(absolutePath))
{
writer.Write(contents);
}
writer.Write(contents);
}
}
/// <summary>
/// Deletes all files passed in.
/// </summary>
/// <param name="files"></param>
/// <param name="onError"></param>
/// <returns></returns>
internal static bool DeleteFiles(IEnumerable<string> files, Action<string, Exception> onError = null)
{
//ensure duplicates are removed
files = files.Distinct();
var allsuccess = true;
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
Parallel.ForEach(files, file =>
{
try
{
if (file.IsNullOrWhiteSpace()) return;
var relativeFilePath = fs.GetRelativePath(file);
if (fs.FileExists(relativeFilePath) == false) return;
var parentDirectory = Path.GetDirectoryName(relativeFilePath);
// don't want to delete the media folder if not using directories.
if (UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/"))
{
//issue U4-771: if there is a parent directory the recursive parameter should be true
fs.DeleteDirectory(parentDirectory, String.IsNullOrEmpty(parentDirectory) == false);
}
else
{
fs.DeleteFile(file, true);
}
}
catch (Exception e)
{
onError?.Invoke(file, e);
allsuccess = false;
}
});
return allsuccess;
}
}
}