comments and don't run internet providers on startup

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-23 08:26:08 -04:00
parent c80c8c1cfd
commit ef03988442
5 changed files with 20 additions and 20 deletions

View File

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO;
namespace MediaBrowser.Common.Serialization
{
/// <summary>
/// Protocol buffers is google's binary serialization format. This is a .NET implementation of it.
/// You have to tag your classes with some annoying attributes, but in return you get the fastest serialization around with the smallest possible output.
/// </summary>
public static class ProtobufSerializer
{
public static void SerializeToStream<T>(T obj, Stream stream)

View File

@ -76,7 +76,7 @@ namespace MediaBrowser.Controller
ReloadUsers();
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 25 });
await ReloadRoot().ConfigureAwait(false);
await ReloadRoot(allowInternetProviders: false).ConfigureAwait(false);
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
}
@ -140,7 +140,7 @@ namespace MediaBrowser.Controller
/// <summary>
/// Reloads the root media folder
/// </summary>
public async Task ReloadRoot()
public async Task ReloadRoot(bool allowInternetProviders = true)
{
if (!Directory.Exists(MediaRootFolderPath))
{
@ -149,7 +149,7 @@ namespace MediaBrowser.Controller
DirectoryWatchers.Stop();
RootFolder = await ItemController.GetItem(MediaRootFolderPath).ConfigureAwait(false) as Folder;
RootFolder = await ItemController.GetItem(MediaRootFolderPath, allowInternetProviders: allowInternetProviders).ConfigureAwait(false) as Folder;
DirectoryWatchers.Start();
}
@ -226,7 +226,7 @@ namespace MediaBrowser.Controller
/// <summary>
/// Runs all metadata providers for an entity
/// </summary>
internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args)
internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args, bool allowInternetProviders = true)
{
// Get all supported providers
BaseMetadataProvider[] supportedProviders = Kernel.Instance.MetadataProviders.Where(i => i.Supports(item)).ToArray();
@ -236,7 +236,7 @@ namespace MediaBrowser.Controller
{
var provider = supportedProviders[i];
if (provider.RequiresInternet && !Configuration.EnableInternetProviders)
if (provider.RequiresInternet && (!Configuration.EnableInternetProviders || !allowInternetProviders))
{
continue;
}

View File

@ -67,7 +67,7 @@ namespace MediaBrowser.Controller.Library
/// <summary>
/// Resolves a path into a BaseItem
/// </summary>
public async Task<BaseItem> GetItem(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null)
public async Task<BaseItem> GetItem(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null, bool allowInternetProviders = true)
{
ItemResolveEventArgs args = new ItemResolveEventArgs()
{
@ -109,12 +109,12 @@ namespace MediaBrowser.Controller.Library
if (item != null)
{
await Kernel.Instance.ExecuteMetadataProviders(item, args).ConfigureAwait(false);
await Kernel.Instance.ExecuteMetadataProviders(item, args, allowInternetProviders: allowInternetProviders).ConfigureAwait(false);
if (item.IsFolder)
{
// If it's a folder look for child entities
(item as Folder).Children = (await Task.WhenAll<BaseItem>(GetChildren(item as Folder, fileSystemChildren)).ConfigureAwait(false))
(item as Folder).Children = (await Task.WhenAll<BaseItem>(GetChildren(item as Folder, fileSystemChildren, allowInternetProviders)).ConfigureAwait(false))
.Where(i => i != null).OrderBy(f =>
{
return string.IsNullOrEmpty(f.SortName) ? f.Name : f.SortName;
@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Library
/// <summary>
/// Finds child BaseItems for a given Folder
/// </summary>
private Task<BaseItem>[] GetChildren(Folder folder, WIN32_FIND_DATA[] fileSystemChildren)
private Task<BaseItem>[] GetChildren(Folder folder, WIN32_FIND_DATA[] fileSystemChildren, bool allowInternetProviders)
{
Task<BaseItem>[] tasks = new Task<BaseItem>[fileSystemChildren.Length];
@ -137,7 +137,7 @@ namespace MediaBrowser.Controller.Library
{
var child = fileSystemChildren[i];
tasks[i] = GetItem(child.Path, folder, child);
tasks[i] = GetItem(child.Path, folder, child, allowInternetProviders: allowInternetProviders);
}
return tasks;

View File

@ -184,6 +184,7 @@ namespace MediaBrowser.Controller.Providers
AudioInfoProvider.EnsureCacheSubFolders(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory);
// This is an optimzation. Do this now so that it doesn't have to be done upon first serialization.
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(FFProbeResult), true);
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaStream), true);
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaFormat), true);

View File

@ -36,7 +36,7 @@ namespace MediaBrowser.TV.Providers
return FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
}
private Task FetchMetadata(Episode item, Season season, string metadataFile)
private async Task FetchMetadata(Episode item, Season season, string metadataFile)
{
if (season == null)
{
@ -44,18 +44,18 @@ namespace MediaBrowser.TV.Providers
// Need to validate it the slow way
if (!File.Exists(metadataFile))
{
return Task.FromResult<object>(null);
await Task.FromResult<object>(null).ConfigureAwait(false);
}
}
else
{
if (!season.ContainsMetadataFile(metadataFile))
{
return Task.FromResult<object>(null);
await Task.FromResult<object>(null).ConfigureAwait(false);
}
}
return Task.Run(() => { new EpisodeXmlParser().Fetch(item, metadataFile); });
await Task.Run(() => { new EpisodeXmlParser().Fetch(item, metadataFile); }).ConfigureAwait(false);
}
}
}