mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-27 20:41:54 +00:00
fixes #200 - MB3 Locking Folders for a long time
This commit is contained in:
@@ -394,9 +394,9 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = FileSystem.GetFileData(path);
|
||||
var data = FileSystem.GetFileSystemInfo(path);
|
||||
|
||||
if (!data.HasValue || data.Value.IsDirectory)
|
||||
if (!data.Exists || data.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
var filename = args.FileInfo.cFileName;
|
||||
var filename = args.FileInfo.Name;
|
||||
|
||||
// Ignore any folders in our list
|
||||
if (IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
||||
|
||||
@@ -403,16 +403,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="fileInfo">The file info.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public BaseItem ResolvePath(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null)
|
||||
public BaseItem ResolvePath(string path, Folder parent = null, FileSystemInfo fileInfo = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
fileInfo = fileInfo ?? FileSystem.GetFileData(path);
|
||||
fileInfo = fileInfo ?? FileSystem.GetFileSystemInfo(path);
|
||||
|
||||
if (!fileInfo.HasValue)
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
Parent = parent,
|
||||
Path = path,
|
||||
FileInfo = fileInfo.Value
|
||||
FileInfo = fileInfo
|
||||
};
|
||||
|
||||
// Return null if ignore rules deem that we should do so
|
||||
@@ -468,7 +468,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="files">The files.</param>
|
||||
/// <param name="parent">The parent.</param>
|
||||
/// <returns>List{``0}.</returns>
|
||||
public List<T> ResolvePaths<T>(IEnumerable<WIN32_FIND_DATA> files, Folder parent)
|
||||
public List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, Folder parent)
|
||||
where T : BaseItem
|
||||
{
|
||||
var list = new List<T>();
|
||||
@@ -477,7 +477,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
var item = ResolvePath(f.Path, parent, f) as T;
|
||||
var item = ResolvePath(f.FullName, parent, f) as T;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
@@ -489,7 +489,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error resolving path {0}", ex, f.Path);
|
||||
_logger.ErrorException("Error resolving path {0}", ex, f.FullName);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -680,16 +680,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
path = Path.Combine(path, FileSystem.GetValidFilename(name));
|
||||
|
||||
var fileInfo = FileSystem.GetFileData(path);
|
||||
var fileInfo = new DirectoryInfo(path);
|
||||
|
||||
var isNew = false;
|
||||
|
||||
if (!fileInfo.HasValue)
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
fileInfo = FileSystem.GetFileData(path);
|
||||
fileInfo = new DirectoryInfo(path);
|
||||
|
||||
if (!fileInfo.HasValue)
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
throw new IOException("Path not created: " + path);
|
||||
}
|
||||
@@ -708,8 +708,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
Name = name,
|
||||
Id = id,
|
||||
DateCreated = fileInfo.Value.CreationTimeUtc,
|
||||
DateModified = fileInfo.Value.LastWriteTimeUtc,
|
||||
DateCreated = fileInfo.CreationTimeUtc,
|
||||
DateModified = fileInfo.LastWriteTimeUtc,
|
||||
Path = path
|
||||
};
|
||||
isNew = true;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
|
||||
{
|
||||
//we use our resolve args name here to get the name of the containg folder, not actual video file
|
||||
item.Name = GetMBName(item.ResolveArgs.FileInfo.cFileName, item.ResolveArgs.FileInfo.IsDirectory);
|
||||
item.Name = GetMBName(item.ResolveArgs.FileInfo.Name, item.ResolveArgs.FileInfo.Attributes.HasFlag(FileAttributes.Directory));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
|
||||
foreach (var fullName in new DirectoryInfo(path).EnumerateFiles("*", SearchOption.TopDirectoryOnly).Select(file => file.FullName))
|
||||
foreach (var fullName in new DirectoryInfo(path).EnumerateFiles().Select(file => file.FullName))
|
||||
{
|
||||
if (AudioResolver.IsAudioFile(fullName)) foundAudio++;
|
||||
if (foundAudio >= 2)
|
||||
@@ -86,19 +86,19 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
/// <param name="list">The list.</param>
|
||||
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
||||
public static bool ContainsMusic(IEnumerable<WIN32_FIND_DATA> list)
|
||||
public static bool ContainsMusic(IEnumerable<FileSystemInfo> list)
|
||||
{
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
|
||||
foreach (var file in list)
|
||||
{
|
||||
if (AudioResolver.IsAudioFile(file.Path)) foundAudio++;
|
||||
if (AudioResolver.IsAudioFile(file.FullName)) foundAudio++;
|
||||
if (foundAudio >= 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (EntityResolutionHelper.IsVideoFile(file.Path)) return false;
|
||||
if (EntityResolutionHelper.IsVideoFile(file.FullName)) return false;
|
||||
}
|
||||
|
||||
// or a single audio file and no video files
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
if (args.Parent.IsRoot) return null;
|
||||
|
||||
// If we contain an album assume we are an artist folder
|
||||
return args.FileSystemChildren.Any(i => MusicAlbumResolver.IsMusicAlbum(i.Path)) ? new MusicArtist() : null;
|
||||
return args.FileSystemChildren.Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
// Loop through each child file/folder and see if we find a video
|
||||
foreach (var child in args.FileSystemChildren)
|
||||
{
|
||||
if (child.IsDirectory)
|
||||
if (child.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
if (IsDvdDirectory(child.cFileName))
|
||||
if (IsDvdDirectory(child.Name))
|
||||
{
|
||||
return new Movie
|
||||
{
|
||||
@@ -137,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
VideoType = VideoType.Dvd
|
||||
};
|
||||
}
|
||||
if (IsBluRayDirectory(child.cFileName))
|
||||
if (IsBluRayDirectory(child.Name))
|
||||
{
|
||||
return new Movie
|
||||
{
|
||||
@@ -145,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
VideoType = VideoType.BluRay
|
||||
};
|
||||
}
|
||||
if (IsHdDvdDirectory(child.cFileName))
|
||||
if (IsHdDvdDirectory(child.Name))
|
||||
{
|
||||
return new Movie
|
||||
{
|
||||
@@ -160,7 +160,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
var childArgs = new ItemResolveArgs(ApplicationPaths)
|
||||
{
|
||||
FileInfo = child,
|
||||
Path = child.Path
|
||||
Path = child.FullName
|
||||
};
|
||||
|
||||
var item = base.Resolve(childArgs);
|
||||
|
||||
Reference in New Issue
Block a user