From 88ff3e4a9bb6ed0db94be7d53f520b224908348b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 10 May 2013 13:49:29 -0400 Subject: [PATCH] fixes #255 - Access to the path is denied. --- .../Providers/ProviderManager.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 1b684610d..840e8265d 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -374,14 +374,6 @@ namespace MediaBrowser.Server.Implementations.Providers try { - // If the file already exists but is hidden, the below save will throw an UnauthorizedAccessException - var existingFileInfo = new FileInfo(localPath); - - if (existingFileInfo.Exists && existingFileInfo.Attributes.HasFlag(FileAttributes.Hidden)) - { - existingFileInfo.Delete(); - } - using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous)) { await img.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false); @@ -476,6 +468,14 @@ namespace MediaBrowser.Server.Implementations.Providers try { + // If the file already exists but is hidden, the below save will throw an UnauthorizedAccessException + var existingFileInfo = new FileInfo(path); + + if (existingFileInfo.Exists && existingFileInfo.Attributes.HasFlag(FileAttributes.Hidden)) + { + existingFileInfo.Delete(); + } + using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous)) { using (dataToSave)