Tweaked disk access a little bit more
This commit is contained in:
parent
9029d939f3
commit
76d365fcf9
|
@ -84,35 +84,25 @@ namespace MediaBrowser.Controller.Events
|
|||
/// </summary>
|
||||
public class PreBeginResolveEventArgs : EventArgs
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public Folder Parent { get; set; }
|
||||
|
||||
public bool Cancel { get; set; }
|
||||
|
||||
public FileAttributes FileAttributes { get { return FileData.dwFileAttributes; } }
|
||||
public WIN32_FIND_DATA FileData { get; set; }
|
||||
public LazyFileInfo File { get; set; }
|
||||
|
||||
public bool IsFolder
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
return FileAttributes.HasFlag(FileAttributes.Directory);
|
||||
return File.Path;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHidden
|
||||
public bool IsDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return FileAttributes.HasFlag(FileAttributes.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSystemFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return FileAttributes.HasFlag(FileAttributes.System);
|
||||
return File.FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,22 @@ namespace MediaBrowser.Controller.IO
|
|||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = FileData.MAX_ALTERNATE)]
|
||||
public string cAlternate;
|
||||
|
||||
public bool IsHidden
|
||||
{
|
||||
get
|
||||
{
|
||||
return dwFileAttributes.HasFlag(FileAttributes.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSystemFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return dwFileAttributes.HasFlag(FileAttributes.System);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDirectory
|
||||
{
|
||||
get
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace MediaBrowser.Controller
|
|||
/// </summary>
|
||||
void ItemController_PreBeginResolvePath(object sender, PreBeginResolveEventArgs e)
|
||||
{
|
||||
if (e.IsHidden || e.IsSystemFile)
|
||||
if (e.File.FileInfo.IsHidden || e.File.FileInfo.IsSystemFile)
|
||||
{
|
||||
// Ignore hidden files and folders
|
||||
e.Cancel = true;
|
||||
|
@ -129,13 +129,10 @@ namespace MediaBrowser.Controller
|
|||
/// </summary>
|
||||
void ItemController_BeginResolvePath(object sender, ItemResolveEventArgs e)
|
||||
{
|
||||
if (e.IsFolder)
|
||||
if (e.ContainsFile(".ignore"))
|
||||
{
|
||||
if (e.ContainsFile(".ignore"))
|
||||
{
|
||||
// Ignore any folders containing a file called .ignore
|
||||
e.Cancel = true;
|
||||
}
|
||||
// Ignore any folders containing a file called .ignore
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,8 @@ namespace MediaBrowser.Controller.Library
|
|||
{
|
||||
PreBeginResolveEventArgs args = new PreBeginResolveEventArgs()
|
||||
{
|
||||
Path = path,
|
||||
Parent = parent,
|
||||
FileData = fileData,
|
||||
File = new LazyFileInfo() { Path = path, FileInfo = fileData },
|
||||
Cancel = false
|
||||
};
|
||||
|
||||
|
@ -101,9 +100,8 @@ namespace MediaBrowser.Controller.Library
|
|||
|
||||
ItemResolveEventArgs args = new ItemResolveEventArgs()
|
||||
{
|
||||
Path = path,
|
||||
File = new LazyFileInfo() { Path = path, FileInfo = fileData },
|
||||
FileSystemChildren = fileSystemChildren,
|
||||
FileData = fileData,
|
||||
Parent = parent,
|
||||
Cancel = false
|
||||
};
|
||||
|
@ -296,8 +294,7 @@ namespace MediaBrowser.Controller.Library
|
|||
item.DateModified = Directory.GetLastAccessTime(path);
|
||||
|
||||
ItemResolveEventArgs args = new ItemResolveEventArgs();
|
||||
args.Path = path;
|
||||
args.FileData = FileData.GetFileData(path);
|
||||
args.File = new LazyFileInfo() { Path = path };
|
||||
args.FileSystemChildren = ConvertFileSystemEntries(Directory.GetFileSystemEntries(path, "*", SearchOption.TopDirectoryOnly));
|
||||
|
||||
await Kernel.Instance.ExecuteMetadataProviders(item, args).ConfigureAwait(false);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (args.IsFolder)
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
var baseItem = item as BaseItem;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
{
|
||||
// Return audio if the path is a file and has a matching extension
|
||||
|
||||
if (!args.IsFolder)
|
||||
if (!args.IsDirectory)
|
||||
{
|
||||
if (IsAudioFile(args.Path))
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
return;
|
||||
}
|
||||
|
||||
WIN32_FIND_DATA fileData = args.FileData;
|
||||
WIN32_FIND_DATA fileData;
|
||||
|
||||
// See if a different path came out of the resolver than what went in
|
||||
if (!args.Path.Equals(item.Path, StringComparison.OrdinalIgnoreCase))
|
||||
|
@ -97,6 +97,10 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
fileData = FileData.GetFileData(item.Path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileData = args.File.FileInfo;
|
||||
}
|
||||
|
||||
item.DateCreated = fileData.CreationTime;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
|
||||
protected override Folder Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder)
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
return new Folder();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
protected override T Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
// If the path is a file check for a matching extensions
|
||||
if (!args.IsFolder)
|
||||
if (!args.IsDirectory)
|
||||
{
|
||||
if (IsVideoFile(args.Path))
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
|
||||
protected override VirtualFolder Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && args.Parent != null && args.Parent.IsRoot)
|
||||
if (args.IsDirectory && args.Parent != null && args.Parent.IsRoot)
|
||||
{
|
||||
return new VirtualFolder();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Movies.Resolvers
|
|||
{
|
||||
protected override BoxSet Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && (args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase))
|
||||
if ((args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase) && args.IsDirectory)
|
||||
{
|
||||
if (Path.GetFileName(args.Path).IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Movies.Resolvers
|
|||
{
|
||||
protected override Movie Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && (args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase))
|
||||
if ((args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase) && args.IsDirectory)
|
||||
{
|
||||
var metadataFile = args.GetFileSystemEntryByName("movie.xml");
|
||||
|
||||
|
@ -52,8 +52,7 @@ namespace MediaBrowser.Movies.Resolvers
|
|||
|
||||
ItemResolveEventArgs childArgs = new ItemResolveEventArgs()
|
||||
{
|
||||
Path = child.Path,
|
||||
FileData = child.FileInfo,
|
||||
File = child,
|
||||
FileSystemChildren = new LazyFileInfo[] { }
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MediaBrowser.TV
|
|||
|
||||
void ItemController_PreBeginResolvePath(object sender, PreBeginResolveEventArgs e)
|
||||
{
|
||||
if (e.IsFolder && System.IO.Path.GetFileName(e.Path).Equals("metadata", StringComparison.OrdinalIgnoreCase))
|
||||
if (System.IO.Path.GetFileName(e.Path).Equals("metadata", StringComparison.OrdinalIgnoreCase) && e.IsDirectory)
|
||||
{
|
||||
if (e.Parent is Season || e.Parent is Series)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace MediaBrowser.TV.Resolvers
|
|||
{
|
||||
protected override Season Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && args.Parent is Series)
|
||||
if (args.Parent is Series && args.IsDirectory)
|
||||
{
|
||||
Season season = new Season();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace MediaBrowser.TV.Resolvers
|
|||
{
|
||||
protected override Series Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && (args.VirtualFolderCollectionType ?? string.Empty).Equals("TV", StringComparison.OrdinalIgnoreCase))
|
||||
if (args.IsDirectory && (args.VirtualFolderCollectionType ?? string.Empty).Equals("TV", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Optimization to avoid running these tests against Seasons
|
||||
if (args.Parent is Series)
|
||||
|
|
Loading…
Reference in New Issue
Block a user