Post-merge fixing & refactoring (tests ok)

This commit is contained in:
Stephan
2016-11-03 10:39:21 +01:00
parent b26b415096
commit b29bc66026
26 changed files with 203 additions and 224 deletions

View File

@@ -5,21 +5,18 @@ using System.Linq;
namespace Umbraco.Core.IO
{
public class ShadowFileSystem : IFileSystem2
public class ShadowFileSystem : IFileSystem
{
private readonly IFileSystem _fs;
private readonly IFileSystem2 _sfs;
private readonly IFileSystem _sfs;
public ShadowFileSystem(IFileSystem fs, IFileSystem2 sfs)
public ShadowFileSystem(IFileSystem fs, IFileSystem sfs)
{
_fs = fs;
_sfs = sfs;
}
public IFileSystem Inner
{
get { return _fs; }
}
public IFileSystem Inner => _fs;
public void Complete()
{
@@ -65,7 +62,7 @@ namespace Umbraco.Core.IO
private Dictionary<string, ShadowNode> _nodes;
private Dictionary<string, ShadowNode> Nodes { get { return _nodes ?? (_nodes = new Dictionary<string, ShadowNode>()); } }
private Dictionary<string, ShadowNode> Nodes => _nodes ?? (_nodes = new Dictionary<string, ShadowNode>());
private class ShadowNode
{
@@ -75,11 +72,11 @@ namespace Umbraco.Core.IO
IsDir = isdir;
}
public bool IsDelete { get; private set; }
public bool IsDir { get; private set; }
public bool IsDelete { get; }
public bool IsDir { get; }
public bool IsExist { get { return IsDelete == false; } }
public bool IsFile { get { return IsDir == false; } }
public bool IsExist => IsDelete == false;
public bool IsFile => IsDir == false;
}
private static string NormPath(string path)
@@ -273,12 +270,8 @@ namespace Umbraco.Core.IO
{
ShadowNode sf;
if (Nodes.TryGetValue(NormPath(path), out sf) == false)
{
// the inner filesystem (_fs) can be IFileSystem2... or just IFileSystem
// figure it out and use the most effective GetSize method
var fs2 = _fs as IFileSystem2;
return fs2 == null ? _fs.GetSize(path) : fs2.GetSize(path);
}
return _fs.GetSize(path);
if (sf.IsDelete || sf.IsDir) throw new InvalidOperationException("Invalid path.");
return _sfs.GetSize(path);
}