From 12cdd3326aa18932e4ce043f0385b284ebc43c91 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 25 Jun 2014 16:00:21 +0200 Subject: [PATCH] The CopyFile extension method was not disposing the file stream, so any attempt to delete the source file afterwards would fail. Removing unused using statements. --- src/Umbraco.Core/IO/FileSystemExtensions.cs | 6 ++++-- src/Umbraco.Core/IO/FileSystemWrapper.cs | 1 - src/Umbraco.Core/IO/IFileSystem.cs | 1 - src/Umbraco.Core/IO/PhysicalFileSystem.cs | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Core/IO/FileSystemExtensions.cs b/src/Umbraco.Core/IO/FileSystemExtensions.cs index a4a40d37ba..6edc52eeb1 100644 --- a/src/Umbraco.Core/IO/FileSystemExtensions.cs +++ b/src/Umbraco.Core/IO/FileSystemExtensions.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using Umbraco.Core.CodeAnnotations; namespace Umbraco.Core.IO { @@ -19,7 +18,10 @@ namespace Umbraco.Core.IO public static void CopyFile(this IFileSystem fs, string path, string newPath) { - fs.AddFile(newPath, fs.OpenFile(path)); + using (var fileStream = fs.OpenFile(path)) + { + fs.AddFile(newPath, fileStream); + } } public static string GetExtension(this IFileSystem fs, string path) diff --git a/src/Umbraco.Core/IO/FileSystemWrapper.cs b/src/Umbraco.Core/IO/FileSystemWrapper.cs index 924485db43..ba2ad8f48b 100644 --- a/src/Umbraco.Core/IO/FileSystemWrapper.cs +++ b/src/Umbraco.Core/IO/FileSystemWrapper.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using Umbraco.Core.CodeAnnotations; namespace Umbraco.Core.IO { diff --git a/src/Umbraco.Core/IO/IFileSystem.cs b/src/Umbraco.Core/IO/IFileSystem.cs index 113f63565c..82baae6fb8 100644 --- a/src/Umbraco.Core/IO/IFileSystem.cs +++ b/src/Umbraco.Core/IO/IFileSystem.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using Umbraco.Core.CodeAnnotations; namespace Umbraco.Core.IO { diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 74d7f27671..bdba541ea3 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -3,10 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Web; -using Umbraco.Core.CodeAnnotations; using Umbraco.Core.Logging; -using Umbraco.Core.Publishing; namespace Umbraco.Core.IO {