mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 13:23:03 +02:00
fixes #255 - Access to the path is denied
This commit is contained in:
parent
1b75668d00
commit
6a740f7ea5
|
@ -269,7 +269,9 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
// Record the name of each file
|
// 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
|
// 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);
|
sb.Append(file.Name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
|
|
||||||
var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
|
var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly)
|
var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly);
|
||||||
.Where(i => !i.Attributes.HasFlag(FileAttributes.System) && !i.Name.Equals(".") && !i.Name.Equals(".."));
|
|
||||||
|
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
|
|
|
@ -470,14 +470,6 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||||
{
|
{
|
||||||
using (dataToSave)
|
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))
|
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);
|
await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
Loading…
Reference in a new issue