Adds in private method EnsureFileExists as it was removed from IOHelper
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user