fixes #255 - Access to the path is denied

This commit is contained in:
Luke Pulverenti 2013-05-10 15:21:55 -04:00
parent 1b75668d00
commit 6a740f7ea5
3 changed files with 4 additions and 11 deletions

View file

@ -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);
}

View file

@ -32,8 +32,7 @@ namespace MediaBrowser.Controller.IO
var dict = new Dictionary<string, FileSystemInfo>(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)
{

View file

@ -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);