Fixes: U4-5190 Overwrite Media File in 6.2.1 - process cannot access along with a bunch of other undisposed disposables :/

This commit is contained in:
Shannon
2014-07-10 11:45:57 +10:00
parent b3c41e051f
commit 874f464a2b
6 changed files with 88 additions and 71 deletions

View File

@@ -93,10 +93,16 @@ namespace Umbraco.Core.IO
public void AddFile(string path, Stream stream, bool overrideIfExists)
{
if (FileExists(path) && !overrideIfExists) throw new InvalidOperationException(string.Format("A file at path '{0}' already exists", path));
var exists = FileExists(path);
if (exists && overrideIfExists == false) throw new InvalidOperationException(string.Format("A file at path '{0}' already exists", path));
EnsureDirectory(Path.GetDirectoryName(path));
if (exists)
{
DeleteFile(path);
}
if (stream.CanSeek)
stream.Seek(0, 0);