diff --git a/src/Umbraco.Core/IO/FileSecurityException.cs b/src/Umbraco.Abstractions/IO/FileSecurityException.cs similarity index 100% rename from src/Umbraco.Core/IO/FileSecurityException.cs rename to src/Umbraco.Abstractions/IO/FileSecurityException.cs diff --git a/src/Umbraco.Core/IO/FileSystemExtensions.cs b/src/Umbraco.Abstractions/IO/FileSystemExtensions.cs similarity index 97% rename from src/Umbraco.Core/IO/FileSystemExtensions.cs rename to src/Umbraco.Abstractions/IO/FileSystemExtensions.cs index e0f5af75c5..444f312153 100644 --- a/src/Umbraco.Core/IO/FileSystemExtensions.cs +++ b/src/Umbraco.Abstractions/IO/FileSystemExtensions.cs @@ -55,7 +55,7 @@ namespace Umbraco.Core.IO } // TODO: Currently this is the only way to do this - internal static void CreateFolder(this IFileSystem fs, string folderPath) + public static void CreateFolder(this IFileSystem fs, string folderPath) { var path = fs.GetRelativePath(folderPath); var tempFile = Path.Combine(path, Guid.NewGuid().ToString("N") + ".tmp"); diff --git a/src/Umbraco.Core/IO/FileSystemWrapper.cs b/src/Umbraco.Abstractions/IO/FileSystemWrapper.cs similarity index 100% rename from src/Umbraco.Core/IO/FileSystemWrapper.cs rename to src/Umbraco.Abstractions/IO/FileSystemWrapper.cs diff --git a/src/Umbraco.Core/IO/FileSystems.cs b/src/Umbraco.Abstractions/IO/FileSystems.cs similarity index 92% rename from src/Umbraco.Core/IO/FileSystems.cs rename to src/Umbraco.Abstractions/IO/FileSystems.cs index 339256789f..00fe0b551b 100644 --- a/src/Umbraco.Core/IO/FileSystems.cs +++ b/src/Umbraco.Abstractions/IO/FileSystems.cs @@ -59,7 +59,7 @@ namespace Umbraco.Core.IO } // set by the scope provider when taking control of filesystems - internal Func IsScoped { get; set; } = () => false; + public Func IsScoped { get; set; } = () => false; #endregion @@ -124,17 +124,17 @@ namespace Umbraco.Core.IO // but it does not really matter what we return - here, null private object CreateWellKnownFileSystems() { - var macroPartialFileSystem = new PhysicalFileSystem(Constants.SystemDirectories.MacroPartials, _ioHelper); - var partialViewsFileSystem = new PhysicalFileSystem(Constants.SystemDirectories.PartialViews, _ioHelper); - var stylesheetsFileSystem = new PhysicalFileSystem(_globalSettings.UmbracoCssPath, _ioHelper); - var scriptsFileSystem = new PhysicalFileSystem(_globalSettings.UmbracoScriptsPath, _ioHelper); - var mvcViewsFileSystem = new PhysicalFileSystem(Constants.SystemDirectories.MvcViews, _ioHelper); + var macroPartialFileSystem = new PhysicalFileSystem(_ioHelper, _logger, Constants.SystemDirectories.MacroPartials); + var partialViewsFileSystem = new PhysicalFileSystem(_ioHelper, _logger, Constants.SystemDirectories.PartialViews); + var stylesheetsFileSystem = new PhysicalFileSystem(_ioHelper, _logger, _globalSettings.UmbracoCssPath); + var scriptsFileSystem = new PhysicalFileSystem(_ioHelper, _logger, _globalSettings.UmbracoScriptsPath); + var mvcViewsFileSystem = new PhysicalFileSystem(_ioHelper, _logger, Constants.SystemDirectories.MvcViews); - _macroPartialFileSystem = new ShadowWrapper(macroPartialFileSystem, "macro-partials", _ioHelper, IsScoped); - _partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, "partials", _ioHelper, IsScoped); - _stylesheetsFileSystem = new ShadowWrapper(stylesheetsFileSystem, "css", _ioHelper, IsScoped); - _scriptsFileSystem = new ShadowWrapper(scriptsFileSystem, "scripts", _ioHelper, IsScoped); - _mvcViewsFileSystem = new ShadowWrapper(mvcViewsFileSystem, "views", _ioHelper, IsScoped); + _macroPartialFileSystem = new ShadowWrapper(macroPartialFileSystem, _ioHelper, _logger,"macro-partials", IsScoped); + _partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, _ioHelper, _logger,"partials", IsScoped); + _stylesheetsFileSystem = new ShadowWrapper(stylesheetsFileSystem, _ioHelper, _logger,"css", IsScoped); + _scriptsFileSystem = new ShadowWrapper(scriptsFileSystem, _ioHelper, _logger,"scripts", IsScoped); + _mvcViewsFileSystem = new ShadowWrapper(mvcViewsFileSystem, _ioHelper, _logger,"views", IsScoped); // TODO: do we need a lock here? _shadowWrappers.Add(_macroPartialFileSystem); @@ -212,7 +212,7 @@ namespace Umbraco.Core.IO // global shadow for the entire application, so great care should be taken to ensure that the // application is *not* doing anything else when using a shadow. - internal ICompletable Shadow() + public ICompletable Shadow() { if (Volatile.Read(ref _wkfsInitialized) == false) EnsureWellKnownFileSystems(); @@ -274,7 +274,7 @@ namespace Umbraco.Core.IO { lock (_shadowLocker) { - var wrapper = new ShadowWrapper(filesystem, shadowPath, _ioHelper, IsScoped); + var wrapper = new ShadowWrapper(filesystem, _ioHelper, _logger, shadowPath, IsScoped); if (_shadowCurrentId != null) wrapper.Shadow(_shadowCurrentId); _shadowWrappers.Add(wrapper); diff --git a/src/Umbraco.Core/IO/IMediaFileSystem.cs b/src/Umbraco.Abstractions/IO/IMediaFileSystem.cs similarity index 100% rename from src/Umbraco.Core/IO/IMediaFileSystem.cs rename to src/Umbraco.Abstractions/IO/IMediaFileSystem.cs diff --git a/src/Umbraco.Core/IO/IMediaPathScheme.cs b/src/Umbraco.Abstractions/IO/IMediaPathScheme.cs similarity index 100% rename from src/Umbraco.Core/IO/IMediaPathScheme.cs rename to src/Umbraco.Abstractions/IO/IMediaPathScheme.cs diff --git a/src/Umbraco.Core/IO/MediaFileSystem.cs b/src/Umbraco.Abstractions/IO/MediaFileSystem.cs similarity index 100% rename from src/Umbraco.Core/IO/MediaFileSystem.cs rename to src/Umbraco.Abstractions/IO/MediaFileSystem.cs diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs b/src/Umbraco.Abstractions/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs similarity index 100% rename from src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs rename to src/Umbraco.Abstractions/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs b/src/Umbraco.Abstractions/IO/MediaPathSchemes/OriginalMediaPathScheme.cs similarity index 100% rename from src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs rename to src/Umbraco.Abstractions/IO/MediaPathSchemes/OriginalMediaPathScheme.cs diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs b/src/Umbraco.Abstractions/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs similarity index 100% rename from src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs rename to src/Umbraco.Abstractions/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs b/src/Umbraco.Abstractions/IO/MediaPathSchemes/UniqueMediaPathScheme.cs similarity index 100% rename from src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs rename to src/Umbraco.Abstractions/IO/MediaPathSchemes/UniqueMediaPathScheme.cs diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Abstractions/IO/PhysicalFileSystem.cs similarity index 92% rename from src/Umbraco.Core/IO/PhysicalFileSystem.cs rename to src/Umbraco.Abstractions/IO/PhysicalFileSystem.cs index 4fc502e63f..01b58ec3cd 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Abstractions/IO/PhysicalFileSystem.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.Exceptions; using System.Threading; using Umbraco.Core.Logging; @@ -12,6 +11,7 @@ namespace Umbraco.Core.IO public class PhysicalFileSystem : IFileSystem { private readonly IIOHelper _ioHelper; + private readonly ILogger _logger; // the rooted, filesystem path, using directory separator chars, NOT ending with a separator // eg "c:" or "c:\path\to\site" or "\\server\path" @@ -28,26 +28,29 @@ namespace Umbraco.Core.IO // virtualRoot should be "~/path/to/root" eg "~/Views" // the "~/" is mandatory. - public PhysicalFileSystem(string virtualRoot, IIOHelper ioHelper) + public PhysicalFileSystem(IIOHelper ioHelper, ILogger logger, string virtualRoot) { + _ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + if (virtualRoot == null) throw new ArgumentNullException("virtualRoot"); if (virtualRoot.StartsWith("~/") == false) throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'"); - _ioHelper = ioHelper; - - _rootPath = EnsureDirectorySeparatorChar(ioHelper.MapPath(virtualRoot)).TrimEnd(Path.DirectorySeparatorChar); + _rootPath = EnsureDirectorySeparatorChar(_ioHelper.MapPath(virtualRoot)).TrimEnd(Path.DirectorySeparatorChar); _rootPathFwd = EnsureUrlSeparatorChar(_rootPath); - _rootUrl = EnsureUrlSeparatorChar(ioHelper.ResolveUrl(virtualRoot)).TrimEnd('/'); + _rootUrl = EnsureUrlSeparatorChar(_ioHelper.ResolveUrl(virtualRoot)).TrimEnd('/'); } - public PhysicalFileSystem(string rootPath, string rootUrl, IIOHelper ioHelper) + public PhysicalFileSystem(IIOHelper ioHelper, ILogger logger, string rootPath, string rootUrl) { + _ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + if (string.IsNullOrEmpty(rootPath)) throw new ArgumentNullOrEmptyException(nameof(rootPath)); if (string.IsNullOrEmpty(rootUrl)) throw new ArgumentNullOrEmptyException(nameof(rootUrl)); if (rootPath.StartsWith("~/")) throw new ArgumentException("The rootPath argument cannot be a virtual path and cannot start with '~/'"); - _ioHelper = ioHelper; // rootPath should be... rooted, as in, it's a root path! if (Path.IsPathRooted(rootPath) == false) @@ -79,11 +82,11 @@ namespace Umbraco.Core.IO } catch (UnauthorizedAccessException ex) { - Current.Logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); + _logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); } catch (DirectoryNotFoundException ex) { - Current.Logger.Error(ex, "Directory not found for '{Path}'", fullPath); + _logger.Error(ex, "Directory not found for '{Path}'", fullPath); } return Enumerable.Empty(); @@ -115,7 +118,7 @@ namespace Umbraco.Core.IO } catch (DirectoryNotFoundException ex) { - Current.Logger.Error(ex, "Directory not found for '{Path}'", fullPath); + _logger.Error(ex, "Directory not found for '{Path}'", fullPath); } } @@ -195,11 +198,11 @@ namespace Umbraco.Core.IO } catch (UnauthorizedAccessException ex) { - Current.Logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); + _logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); } catch (DirectoryNotFoundException ex) { - Current.Logger.Error(ex, "Directory not found for '{FullPath}'", fullPath); + _logger.Error(ex, "Directory not found for '{FullPath}'", fullPath); } return Enumerable.Empty(); @@ -232,7 +235,7 @@ namespace Umbraco.Core.IO } catch (FileNotFoundException ex) { - Current.Logger.Error(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath); + _logger.Error(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath); } } diff --git a/src/Umbraco.Core/IO/ShadowFileSystem.cs b/src/Umbraco.Abstractions/IO/ShadowFileSystem.cs similarity index 100% rename from src/Umbraco.Core/IO/ShadowFileSystem.cs rename to src/Umbraco.Abstractions/IO/ShadowFileSystem.cs diff --git a/src/Umbraco.Core/IO/ShadowFileSystems.cs b/src/Umbraco.Abstractions/IO/ShadowFileSystems.cs similarity index 100% rename from src/Umbraco.Core/IO/ShadowFileSystems.cs rename to src/Umbraco.Abstractions/IO/ShadowFileSystems.cs diff --git a/src/Umbraco.Core/IO/ShadowWrapper.cs b/src/Umbraco.Abstractions/IO/ShadowWrapper.cs similarity index 93% rename from src/Umbraco.Core/IO/ShadowWrapper.cs rename to src/Umbraco.Abstractions/IO/ShadowWrapper.cs index b51b36f591..ff2af4a554 100644 --- a/src/Umbraco.Core/IO/ShadowWrapper.cs +++ b/src/Umbraco.Abstractions/IO/ShadowWrapper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Umbraco.Core.Composing; +using Umbraco.Core.Logging; namespace Umbraco.Core.IO { @@ -12,16 +13,18 @@ namespace Umbraco.Core.IO private readonly Func _isScoped; private readonly IFileSystem _innerFileSystem; - private readonly IIOHelper _ioHelper; private readonly string _shadowPath; private ShadowFileSystem _shadowFileSystem; private string _shadowDir; + private readonly IIOHelper _ioHelper; + private readonly ILogger _logger; - public ShadowWrapper(IFileSystem innerFileSystem, string shadowPath, IIOHelper ioHelper, Func isScoped = null) + public ShadowWrapper(IFileSystem innerFileSystem, IIOHelper ioHelper, ILogger logger, string shadowPath, Func isScoped = null) { _innerFileSystem = innerFileSystem; + _ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _shadowPath = shadowPath; - _ioHelper = ioHelper; _isScoped = isScoped; } @@ -60,7 +63,7 @@ namespace Umbraco.Core.IO var virt = ShadowFsPath + "/" + id + "/" + _shadowPath; _shadowDir = _ioHelper.MapPath(virt); Directory.CreateDirectory(_shadowDir); - var tempfs = new PhysicalFileSystem(virt, _ioHelper); + var tempfs = new PhysicalFileSystem(_ioHelper, _logger, virt); _shadowFileSystem = new ShadowFileSystem(_innerFileSystem, tempfs); } diff --git a/src/Umbraco.Core/IO/SupportingFileSystems.cs b/src/Umbraco.Abstractions/IO/SupportingFileSystems.cs similarity index 100% rename from src/Umbraco.Core/IO/SupportingFileSystems.cs rename to src/Umbraco.Abstractions/IO/SupportingFileSystems.cs diff --git a/src/Umbraco.Core/IO/ViewHelper.cs b/src/Umbraco.Abstractions/IO/ViewHelper.cs similarity index 99% rename from src/Umbraco.Core/IO/ViewHelper.cs rename to src/Umbraco.Abstractions/IO/ViewHelper.cs index 63f7504f18..d8bf561704 100644 --- a/src/Umbraco.Core/IO/ViewHelper.cs +++ b/src/Umbraco.Abstractions/IO/ViewHelper.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.IO return _viewFileSystem.FileExists(ViewPath(t.Alias)); } - internal string GetFileContents(ITemplate t) + public string GetFileContents(ITemplate t) { var viewContent = ""; var path = ViewPath(t.Alias); diff --git a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj index 4fbb43e33d..7e00359c37 100644 --- a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj +++ b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj @@ -15,4 +15,13 @@ + + + <_Parameter1>Umbraco.Tests + + + <_Parameter1>Umbraco.Tests.Benchmarks + + + diff --git a/src/Umbraco.Core/Composing/CompositionExtensions/FileSystems.cs b/src/Umbraco.Core/Composing/CompositionExtensions/FileSystems.cs index 62c9e0ae0c..0fdcd0ae29 100644 --- a/src/Umbraco.Core/Composing/CompositionExtensions/FileSystems.cs +++ b/src/Umbraco.Core/Composing/CompositionExtensions/FileSystems.cs @@ -1,7 +1,6 @@ -using Umbraco.Core.Compose; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; +using Umbraco.Core.IO; using Umbraco.Core.IO.MediaPathSchemes; +using Umbraco.Core.Logging; namespace Umbraco.Core.Composing.CompositionExtensions { @@ -91,7 +90,7 @@ namespace Umbraco.Core.Composing.CompositionExtensions // register the IFileSystem supporting the IMediaFileSystem // THIS IS THE ONLY THING THAT NEEDS TO CHANGE, IN ORDER TO REPLACE THE UNDERLYING FILESYSTEM // and, SupportingFileSystem.For() returns the underlying filesystem - composition.SetMediaFileSystem(factory => new PhysicalFileSystem(factory.GetInstance().UmbracoMediaPath, factory.GetInstance())); + composition.SetMediaFileSystem(factory => new PhysicalFileSystem(factory.GetInstance(), factory.GetInstance(), Current.Configs.Global().UmbracoMediaPath)); return composition; } diff --git a/src/Umbraco.Core/IO/SystemDirectories.cs b/src/Umbraco.Core/IO/SystemDirectories.cs deleted file mode 100644 index bfdd3f33ed..0000000000 --- a/src/Umbraco.Core/IO/SystemDirectories.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Web; -using Umbraco.Core.Composing; - -namespace Umbraco.Core.IO -{ - //all paths has a starting but no trailing / - public class SystemDirectories - { - - - } -} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8575c558de..bd1b0edaa0 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -158,10 +158,8 @@ - - - + @@ -249,10 +247,6 @@ - - - - @@ -364,18 +358,6 @@ - - - - - - - - - - - - diff --git a/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs b/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs index 85c10b4005..85fa79fc0a 100644 --- a/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs @@ -2,8 +2,10 @@ using System.IO; using System.Text; using System.Threading; +using Moq; using NUnit.Framework; using Umbraco.Core.IO; +using Umbraco.Core.Logging; namespace Umbraco.Tests.IO @@ -13,8 +15,8 @@ namespace Umbraco.Tests.IO public class PhysicalFileSystemTests : AbstractFileSystemTests { public PhysicalFileSystemTests() - : base(new PhysicalFileSystem(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"), - "/Media/", new IOHelper())) + : base(new PhysicalFileSystem(IOHelper.Default, Mock.Of(), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"), + "/Media/")) { } [SetUp] diff --git a/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs b/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs index d73c6124bc..c73de56835 100644 --- a/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs @@ -53,14 +53,15 @@ namespace Umbraco.Tests.IO public void ShadowDeleteDirectory() { var ioHelper = IOHelper.Default; + var logger = Mock.Of(); var path = ioHelper.MapPath("FileSysTests"); Directory.CreateDirectory(path); Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); Directory.CreateDirectory(path + "/ShadowTests/d1"); @@ -95,8 +96,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); Directory.CreateDirectory(path + "/ShadowTests/sub"); @@ -146,8 +147,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); File.WriteAllText(path + "/ShadowTests/f1.txt", "foo"); @@ -188,8 +189,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); Directory.CreateDirectory(path + "/ShadowTests/sub"); @@ -245,8 +246,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); Assert.Throws(() => @@ -266,8 +267,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); File.WriteAllText(path + "/ShadowTests/f2.txt", "foo"); @@ -307,8 +308,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) @@ -349,8 +350,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) @@ -373,8 +374,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); Directory.CreateDirectory(path + "/ShadowTests/sub/sub"); @@ -414,7 +415,7 @@ namespace Umbraco.Tests.IO var scopedFileSystems = false; - var phy = new PhysicalFileSystem(path, "ignore", ioHelper); + var phy = new PhysicalFileSystem(ioHelper, Current.Logger, path, "ignore"); var container = Mock.Of(); var fileSystems = new FileSystems(container, logger, ioHelper, SettingsForTests.GenerateMockGlobalSettings()) { IsScoped = () => scopedFileSystems }; @@ -509,7 +510,7 @@ namespace Umbraco.Tests.IO var scopedFileSystems = false; - var phy = new PhysicalFileSystem(path, "ignore", ioHelper); + var phy = new PhysicalFileSystem(ioHelper, Current.Logger, path, "ignore"); var container = Mock.Of(); var fileSystems = new FileSystems(container, logger, ioHelper, SettingsForTests.GenerateMockGlobalSettings()) { IsScoped = () => scopedFileSystems }; @@ -563,7 +564,7 @@ namespace Umbraco.Tests.IO var scopedFileSystems = false; - var phy = new PhysicalFileSystem(path, "ignore", ioHelper); + var phy = new PhysicalFileSystem(ioHelper, Current.Logger, path, "ignore"); var container = Mock.Of(); var fileSystems = new FileSystems(container, logger, ioHelper, SettingsForTests.GenerateMockGlobalSettings()) { IsScoped = () => scopedFileSystems }; @@ -679,8 +680,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -713,8 +714,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -750,8 +751,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -784,8 +785,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -821,8 +822,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -870,8 +871,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -906,8 +907,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "ignore", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "ignore"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); // Act @@ -947,8 +948,8 @@ namespace Umbraco.Tests.IO Directory.CreateDirectory(path + "/ShadowTests"); Directory.CreateDirectory(path + "/ShadowSystem"); - var fs = new PhysicalFileSystem(path + "/ShadowTests/", "rootUrl", ioHelper); - var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "rootUrl", ioHelper); + var fs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowTests/", "rootUrl"); + var sfs = new PhysicalFileSystem(ioHelper, Current.Logger, path + "/ShadowSystem/", "rootUrl"); var ss = new ShadowFileSystem(fs, sfs); // Act diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index 92b97f8ca5..d8557230b6 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -31,11 +31,11 @@ namespace Umbraco.Tests.Models // reference, so static ctor runs, so event handlers register // and then, this will reset the width, height... because the file does not exist, of course ;-( var logger = Mock.Of(); + var ioHelper = Mock.Of(); var scheme = Mock.Of(); var config = Mock.Of(); var dataTypeService = Mock.Of(); var localizationService = Mock.Of(); - var ioHelper = Mock.Of(); var mediaFileSystem = new MediaFileSystem(Mock.Of(), config, scheme, logger, ioHelper); var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, config, dataTypeService, localizationService); diff --git a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs index 9fa5488815..4b57b96bb8 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs @@ -22,7 +22,7 @@ namespace Umbraco.Tests.Persistence.Repositories { base.SetUp(); - _fileSystem = new PhysicalFileSystem(Constants.SystemDirectories.MvcViews + "/Partials/", IOHelper); + _fileSystem = new PhysicalFileSystem(IOHelper, Logger, Constants.SystemDirectories.MvcViews + "/Partials/"); } protected override void Compose() diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs index 2d1c92f1b4..dc654a2c52 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs @@ -29,7 +29,7 @@ namespace Umbraco.Tests.Persistence.Repositories base.SetUp(); _fileSystems = Mock.Of(); - _fileSystem = new PhysicalFileSystem(SettingsForTests.GenerateMockGlobalSettings().UmbracoScriptsPath, IOHelper); + _fileSystem = new PhysicalFileSystem(IOHelper, Logger, SettingsForTests.GenerateMockGlobalSettings().UmbracoScriptsPath); Mock.Get(_fileSystems).Setup(x => x.ScriptsFileSystem).Returns(_fileSystem); using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");")) { diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs index d076734037..3106c1692c 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.Persistence.Repositories base.SetUp(); _fileSystems = Mock.Of(); - _fileSystem = new PhysicalFileSystem(SettingsForTests.GenerateMockGlobalSettings().UmbracoCssPath, IOHelper); + _fileSystem = new PhysicalFileSystem(IOHelper, Logger, SettingsForTests.GenerateMockGlobalSettings().UmbracoCssPath); Mock.Get(_fileSystems).Setup(x => x.StylesheetsFileSystem).Returns(_fileSystem); var stream = CreateStream("body {background:#EE7600; color:#FFF;}"); _fileSystem.AddFile("styles.css", stream); diff --git a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs index 522a8c78f6..0bb761a2ac 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs @@ -36,7 +36,7 @@ namespace Umbraco.Tests.Persistence.Repositories base.SetUp(); _fileSystems = Mock.Of(); - var viewsFileSystem = new PhysicalFileSystem(Constants.SystemDirectories.MvcViews, IOHelper); + var viewsFileSystem = new PhysicalFileSystem(IOHelper, Logger, Constants.SystemDirectories.MvcViews); Mock.Get(_fileSystems).Setup(x => x.MvcViewsFileSystem).Returns(viewsFileSystem); } @@ -527,7 +527,7 @@ namespace Umbraco.Tests.Persistence.Repositories _fileSystems = null; //Delete all files - var fsViews = new PhysicalFileSystem(Constants.SystemDirectories.MvcViews, IOHelper); + var fsViews = new PhysicalFileSystem(IOHelper, Logger, Constants.SystemDirectories.MvcViews); var views = fsViews.GetFiles("", "*.cshtml"); foreach (var file in views) fsViews.DeleteFile(file); diff --git a/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs b/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs index b5c441a280..fa0fdd08e2 100644 --- a/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Scoping base.SetUp(); SafeCallContext.Clear(); - ClearFiles(this.IOHelper); + ClearFiles(IOHelper); } protected override void ComposeApplication(bool withApplication) @@ -39,7 +39,7 @@ namespace Umbraco.Tests.Scoping base.TearDown(); SafeCallContext.Clear(); FileSystems.ResetShadowId(); - ClearFiles(this.IOHelper); + ClearFiles(IOHelper); } private static void ClearFiles(IIOHelper ioHelper) @@ -53,7 +53,7 @@ namespace Umbraco.Tests.Scoping [TestCase(false)] public void CreateMediaTest(bool complete) { - var physMediaFileSystem = new PhysicalFileSystem(IOHelper.MapPath("media"), "ignore", IOHelper); + var physMediaFileSystem = new PhysicalFileSystem(IOHelper, Logger, IOHelper.MapPath("media"), "ignore"); var mediaFileSystem = Current.MediaFileSystem; Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt")); @@ -86,7 +86,7 @@ namespace Umbraco.Tests.Scoping [Test] public void MultiThread() { - var physMediaFileSystem = new PhysicalFileSystem(IOHelper.MapPath("media"), "ignore", new IOHelper()); + var physMediaFileSystem = new PhysicalFileSystem(IOHelper, Logger, IOHelper.MapPath("media"), "ignore"); var mediaFileSystem = Current.MediaFileSystem; var scopeProvider = ScopeProvider; diff --git a/src/Umbraco.Web/Editors/BackOfficeAssetsController.cs b/src/Umbraco.Web/Editors/BackOfficeAssetsController.cs index c2eea32d79..7b4f036313 100644 --- a/src/Umbraco.Web/Editors/BackOfficeAssetsController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeAssetsController.cs @@ -2,9 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Web.Http; -using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.IO; +using Umbraco.Core.Logging; using Umbraco.Web.Mvc; namespace Umbraco.Web.Editors @@ -14,11 +15,9 @@ namespace Umbraco.Web.Editors { private readonly IFileSystem _jsLibFileSystem; - public BackOfficeAssetsController(IIOHelper ioHelper) + public BackOfficeAssetsController(IIOHelper ioHelper, ILogger logger, IGlobalSettings globalSettings) { - _jsLibFileSystem = - new PhysicalFileSystem(Current.Configs.Global().UmbracoPath + Current.IOHelper.DirSepChar + "lib", - ioHelper); + _jsLibFileSystem = new PhysicalFileSystem(ioHelper, logger, globalSettings.UmbracoPath + ioHelper.DirSepChar + "lib"); } [HttpGet] diff --git a/src/Umbraco.Web/Trees/FilesTreeController.cs b/src/Umbraco.Web/Trees/FilesTreeController.cs index 0a15ae32ea..e9e9070c09 100644 --- a/src/Umbraco.Web/Trees/FilesTreeController.cs +++ b/src/Umbraco.Web/Trees/FilesTreeController.cs @@ -1,6 +1,6 @@ using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Web.Models.Trees; +using Umbraco.Core.Logging; namespace Umbraco.Web.Trees { @@ -9,16 +9,18 @@ namespace Umbraco.Web.Trees public class FilesTreeController : FileSystemTreeController { private readonly IIOHelper _ioHelper; + private readonly ILogger _logger; private readonly IFileSystem _fileSystem; protected override IFileSystem FileSystem => _fileSystem; private static readonly string[] ExtensionsStatic = { "*" }; - public FilesTreeController(IIOHelper ioHelper) + public FilesTreeController(IIOHelper ioHelper, ILogger logger) { _ioHelper = ioHelper; - _fileSystem = new PhysicalFileSystem("~/", _ioHelper); + _logger = logger; + _fileSystem = new PhysicalFileSystem(_ioHelper, _logger, "~/"); } protected override string[] Extensions => ExtensionsStatic;