Merge pull request #7172 from umbraco/netcore/feature/AB3734-move-io-stuff
Netcore: Move most of IO into abstractions
This commit is contained in:
@@ -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");
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
|
||||
// set by the scope provider when taking control of filesystems
|
||||
internal Func<bool> IsScoped { get; set; } = () => false;
|
||||
public Func<bool> 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);
|
||||
@@ -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<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
Current.Logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<string>();
|
||||
@@ -115,7 +118,7 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
Current.Logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,11 +198,11 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
Current.Logger.Error<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
Current.Logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{FullPath}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex, "Directory not found for '{FullPath}'", fullPath);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<string>();
|
||||
@@ -232,7 +235,7 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Current.Logger.Error<PhysicalFileSystem>(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath);
|
||||
_logger.Error<PhysicalFileSystem>(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<bool> _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<bool> isScoped = null)
|
||||
public ShadowWrapper(IFileSystem innerFileSystem, IIOHelper ioHelper, ILogger logger, string shadowPath, Func<bool> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -15,4 +15,13 @@
|
||||
<PackageReference Include="System.Runtime.Caching" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>Umbraco.Tests</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>Umbraco.Tests.Benchmarks</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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<IMediaFileSystem>() returns the underlying filesystem
|
||||
composition.SetMediaFileSystem(factory => new PhysicalFileSystem(factory.GetInstance<IGlobalSettings>().UmbracoMediaPath, factory.GetInstance<IIOHelper>()));
|
||||
composition.SetMediaFileSystem(factory => new PhysicalFileSystem(factory.GetInstance<IIOHelper>(), factory.GetInstance<ILogger>(), Current.Configs.Global().UmbracoMediaPath));
|
||||
|
||||
return composition;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -158,10 +158,8 @@
|
||||
<Compile Include="Composing\Current.cs" />
|
||||
<Compile Include="Composing\LightInject\LightInjectContainer.cs" />
|
||||
<Compile Include="Composing\LightInject\MixedLightInjectScopeManagerProvider.cs" />
|
||||
<Compile Include="IO\IMediaFileSystem.cs" />
|
||||
<Compile Include="IO\IMediaPathScheme.cs" />
|
||||
<Compile Include="IO\IOHelper.cs" />
|
||||
<Compile Include="IO\MediaPathSchemes\UniqueMediaPathScheme.cs" />
|
||||
<Compile Include="IO\SystemFiles.cs" />
|
||||
<Compile Include="Logging\Viewer\LogTimePeriod.cs" />
|
||||
<Compile Include="Manifest\IPackageManifest.cs" />
|
||||
<Compile Include="Manifest\ManifestParser.cs" />
|
||||
@@ -249,10 +247,6 @@
|
||||
<Compile Include="Sync\RefreshInstructionEnvelope.cs" />
|
||||
<Compile Include="TypeExtensions.cs" />
|
||||
<Compile Include="TypeLoaderExtensions.cs" />
|
||||
<Compile Include="IO\MediaPathSchemes\CombinedGuidsMediaPathScheme.cs" />
|
||||
<Compile Include="IO\MediaPathSchemes\OriginalMediaPathScheme.cs" />
|
||||
<Compile Include="IO\MediaPathSchemes\TwoGuidsMediaPathScheme.cs" />
|
||||
<Compile Include="IO\SupportingFileSystems.cs" />
|
||||
<Compile Include="Logging\Viewer\CountingFilter.cs" />
|
||||
<Compile Include="Logging\Viewer\ErrorCounterFilter.cs" />
|
||||
<Compile Include="Logging\Viewer\ExpressionFilter.cs" />
|
||||
@@ -364,18 +358,6 @@
|
||||
<Compile Include="Composing\LightInject\LightInjectException.cs" />
|
||||
<Compile Include="FileResources\Files.Designer.cs" />
|
||||
<Compile Include="HttpContextExtensions.cs" />
|
||||
<Compile Include="IO\FileSecurityException.cs" />
|
||||
<Compile Include="IO\FileSystemExtensions.cs" />
|
||||
<Compile Include="IO\FileSystems.cs" />
|
||||
<Compile Include="IO\FileSystemWrapper.cs" />
|
||||
<Compile Include="IO\MediaFileSystem.cs" />
|
||||
<Compile Include="IO\PhysicalFileSystem.cs" />
|
||||
<Compile Include="IO\ShadowFileSystem.cs" />
|
||||
<Compile Include="IO\ShadowFileSystems.cs" />
|
||||
<Compile Include="IO\ShadowWrapper.cs" />
|
||||
<Compile Include="IO\SystemDirectories.cs" />
|
||||
<Compile Include="IO\SystemFiles.cs" />
|
||||
<Compile Include="IO\ViewHelper.cs" />
|
||||
<Compile Include="Logging\Serilog\SerilogLogger.cs" />
|
||||
<Compile Include="Logging\OwinLogger.cs" />
|
||||
<Compile Include="Logging\OwinLoggerFactory.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<ILogger>(), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"),
|
||||
"/Media/"))
|
||||
{ }
|
||||
|
||||
[SetUp]
|
||||
|
||||
@@ -53,14 +53,15 @@ namespace Umbraco.Tests.IO
|
||||
public void ShadowDeleteDirectory()
|
||||
{
|
||||
var ioHelper = IOHelper.Default;
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
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<FileSecurityException>(() =>
|
||||
@@ -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<IFactory>();
|
||||
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<IFactory>();
|
||||
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<IFactory>();
|
||||
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
|
||||
|
||||
@@ -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<ILogger>();
|
||||
var ioHelper = Mock.Of<IIOHelper>();
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
var config = Mock.Of<IContentSection>();
|
||||
var dataTypeService = Mock.Of<IDataTypeService>();
|
||||
var localizationService = Mock.Of<ILocalizationService>();
|
||||
var ioHelper = Mock.Of<IIOHelper>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
|
||||
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, dataTypeService, localizationService);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_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\");"))
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_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);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user