From 6a740f7ea5aabc5647e49d651e28768bc05554dd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 10 May 2013 15:21:55 -0400 Subject: [PATCH] fixes #255 - Access to the path is denied --- MediaBrowser.Controller/Entities/BaseItem.cs | 4 +++- MediaBrowser.Controller/IO/FileData.cs | 3 +-- .../Providers/ProviderManager.cs | 8 -------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 43c629505d..9f02fdc905 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -269,7 +269,9 @@ namespace MediaBrowser.Controller.Entities // Record the name of each file // Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order - foreach (var file in ResolveArgs.FileSystemChildren.OrderBy(f => f.Name)) + foreach (var file in ResolveArgs.FileSystemChildren + .Where(i => !i.Attributes.HasFlag(FileAttributes.System)) + .OrderBy(f => f.Name)) { sb.Append(file.Name); } diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 3f15d8ddb5..4b5aed3ab7 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -32,8 +32,7 @@ namespace MediaBrowser.Controller.IO var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); - var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly) - .Where(i => !i.Attributes.HasFlag(FileAttributes.System) && !i.Name.Equals(".") && !i.Name.Equals("..")); + var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly); foreach (var entry in entries) { diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 5dfa31b09e..b0a0f8760d 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -470,14 +470,6 @@ namespace MediaBrowser.Server.Implementations.Providers { using (dataToSave) { - // 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)) { await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);