Adds in private method EnsureFileExists as it was removed from IOHelper

This commit is contained in:
Warren Buckley
2019-01-21 11:48:55 +00:00
parent f6154a38d9
commit 1d39c177cc

View File

@@ -32,7 +32,7 @@ namespace Umbraco.Core.Logging.Viewer
//Our default implementation
//If file does not exist - lets create it with an empty array
IOHelper.EnsureFileExists(_searchesConfigPath, "[]");
EnsureFileExists(_searchesConfigPath, "[]");
var rawJson = System.IO.File.ReadAllText(_searchesConfigPath);
return JsonConvert.DeserializeObject<IEnumerable<SavedLogSearch>>(rawJson);
@@ -50,7 +50,7 @@ namespace Umbraco.Core.Logging.Viewer
var rawJson = JsonConvert.SerializeObject(searches, Formatting.Indented);
//If file does not exist - lets create it with an empty array
IOHelper.EnsureFileExists(_searchesConfigPath, "[]");
EnsureFileExists(_searchesConfigPath, "[]");
//Write it back down to file
System.IO.File.WriteAllText(_searchesConfigPath, rawJson);
@@ -163,6 +163,15 @@ namespace Umbraco.Core.Logging.Viewer
};
}
private void EnsureFileExists(string path, string contents)
{
var absolutePath = IOHelper.MapPath(path);
if (System.IO.File.Exists(absolutePath)) return;
using (var writer = System.IO.File.CreateText(absolutePath))
{
writer.Write(contents);
}
}
}
}