fix config startup

This commit is contained in:
Luke Pulverenti 2014-06-30 09:28:38 -04:00
parent 62d98551ed
commit f0da58a997
4 changed files with 51 additions and 11 deletions

View File

@ -96,5 +96,10 @@ namespace MediaBrowser.Controller.Entities
{
return Name;
}
public bool IsType(string type)
{
return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase);
}
}
}

View File

@ -423,7 +423,38 @@ namespace MediaBrowser.Server.Implementations.Dto
// Ordering by person type to ensure actors and artists are at the front.
// This is taking advantage of the fact that they both begin with A
// This should be improved in the future
var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue).ThenBy(i => i.Type).ToList();
var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue)
.ThenBy(i =>
{
if (i.IsType(PersonType.Actor))
{
return 0;
}
if (i.IsType(PersonType.GuestStar))
{
return 1;
}
if (i.IsType(PersonType.Director))
{
return 2;
}
if (i.IsType(PersonType.Writer))
{
return 3;
}
if (i.IsType(PersonType.Producer))
{
return 4;
}
if (i.IsType(PersonType.Composer))
{
return 4;
}
return 10;
})
.ThenBy(i => i.Name)
.ToList();
// Attach People by transforming them into BaseItemPerson (DTO)
dto.People = new BaseItemPerson[people.Count];

View File

@ -277,19 +277,19 @@ namespace MediaBrowser.ServerApplication
LogManager.RemoveConsoleOutput();
}
public override Task Init(IProgress<double> progress)
public override async Task Init(IProgress<double> progress)
{
PerformVersionMigration();
return base.Init(progress);
await base.Init(progress).ConfigureAwait(false);
MigrateModularConfigurations();
ApplyDefaultMetadataSettings();
}
private void PerformVersionMigration()
{
DeleteDeprecatedModules();
MigrateModularConfigurations();
ApplyDefaultMetadataSettings();
}
private void MigrateModularConfigurations()

View File

@ -382,8 +382,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
}
var writers = item.People
.Where(i => IsPersonType(i, PersonType.Director))
.Where(i => IsPersonType(i, PersonType.Writer))
.Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
foreach (var person in writers)
@ -391,11 +392,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
builder.Append("<writer>" + SecurityElement.Escape(person) + "</writer>");
}
var credits = writers.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
if (credits.Count > 0)
if (writers.Count > 0)
{
builder.Append("<credits>" + SecurityElement.Escape(string.Join(" / ", credits.ToArray())) + "</credits>");
builder.Append("<credits>" + SecurityElement.Escape(string.Join(" / ", writers.ToArray())) + "</credits>");
}
var hasTrailer = item as IHasTrailers;
@ -850,6 +849,11 @@ namespace MediaBrowser.XbmcMetadata.Savers
builder.Append("<role>" + SecurityElement.Escape(person.Role ?? string.Empty) + "</role>");
builder.Append("<type>" + SecurityElement.Escape(person.Type ?? string.Empty) + "</type>");
if (person.SortOrder.HasValue)
{
builder.Append("<sortorder>" + SecurityElement.Escape(person.SortOrder.Value.ToString(UsCulture)) + "</sortorder>");
}
try
{
var personEntity = libraryManager.GetPerson(person.Name);