fix library scan stopping and restarting itself

pull/702/head
Luke Pulverenti 11 years ago
parent ab490d7467
commit ed34b67f51

@ -275,7 +275,10 @@ namespace MediaBrowser.Model.Configuration
MetadataCountryCode = "US"; MetadataCountryCode = "US";
DownloadMovieImages = new ImageDownloadOptions(); DownloadMovieImages = new ImageDownloadOptions();
DownloadSeriesImages = new ImageDownloadOptions(); DownloadSeriesImages = new ImageDownloadOptions();
DownloadSeasonImages = new ImageDownloadOptions(); DownloadSeasonImages = new ImageDownloadOptions
{
Backdrops = false
};
DownloadMusicArtistImages = new ImageDownloadOptions(); DownloadMusicArtistImages = new ImageDownloadOptions();
DownloadMusicAlbumImages = new ImageDownloadOptions(); DownloadMusicAlbumImages = new ImageDownloadOptions();
MaxBackdrops = 3; MaxBackdrops = 3;

@ -221,7 +221,7 @@ namespace MediaBrowser.Providers.Movies
!imagesFileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(imagesFileInfo) > providerInfo.LastRefreshed; !imagesFileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(imagesFileInfo) > providerInfo.LastRefreshed;
} }
return true; return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
} }
/// <summary> /// <summary>

@ -562,8 +562,8 @@ namespace MediaBrowser.Providers.Savers
{ {
var timespan = TimeSpan.FromTicks(item.RunTimeTicks.Value); var timespan = TimeSpan.FromTicks(item.RunTimeTicks.Value);
builder.Append("<Duration>" + Convert.ToInt32(timespan.TotalMinutes).ToString(UsCulture) + "</Duration>"); builder.Append("<Duration>" + Convert.ToInt64(timespan.TotalMinutes).ToString(UsCulture) + "</Duration>");
builder.Append("<DurationSeconds>" + Convert.ToInt32(timespan.TotalSeconds).ToString(UsCulture) + "</DurationSeconds>"); builder.Append("<DurationSeconds>" + Convert.ToInt64(timespan.TotalSeconds).ToString(UsCulture) + "</DurationSeconds>");
} }
if (video != null && video.Video3DFormat.HasValue) if (video != null && video.Video3DFormat.HasValue)

@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.TV
try try
{ {
var fanartData = FetchFanartXmlData(imagesXmlPath, seasonNumber.Value, cancellationToken); var fanartData = FetchFanartXmlData(imagesXmlPath, seasonNumber.Value, cancellationToken);
await DownloadImages(item, fanartData, 1, cancellationToken).ConfigureAwait(false); await DownloadImages(item, fanartData, ConfigurationManager.Configuration.MaxBackdrops, cancellationToken).ConfigureAwait(false);
} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {

@ -361,7 +361,33 @@ namespace MediaBrowser.Server.Implementations.IO
if (e.ChangeType == WatcherChangeTypes.Changed) if (e.ChangeType == WatcherChangeTypes.Changed)
{ {
// If the parent of an ignored path has a change event, ignore that too // If the parent of an ignored path has a change event, ignore that too
if (tempIgnorePaths.Any(i => string.Equals(Path.GetDirectoryName(i), e.FullPath, StringComparison.OrdinalIgnoreCase) || string.Equals(i, e.FullPath, StringComparison.OrdinalIgnoreCase))) if (tempIgnorePaths.Any(i =>
{
if (string.Equals(i, e.FullPath, StringComparison.OrdinalIgnoreCase))
{
return true;
}
// Go up a level
var parent = Path.GetDirectoryName(i);
if (string.Equals(parent, e.FullPath, StringComparison.OrdinalIgnoreCase))
{
return true;
}
// Go up another level
if (!string.IsNullOrEmpty(parent))
{
parent = Path.GetDirectoryName(i);
if (string.Equals(parent, e.FullPath, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}))
{ {
return; return;
} }

@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db"); var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = { string[] queries = {

@ -128,15 +128,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// Connects to db. /// Connects to db.
/// </summary> /// </summary>
/// <param name="dbPath">The db path.</param> /// <param name="dbPath">The db path.</param>
/// <param name="logger">The logger.</param>
/// <returns>Task{IDbConnection}.</returns> /// <returns>Task{IDbConnection}.</returns>
/// <exception cref="System.ArgumentNullException">dbPath</exception> /// <exception cref="System.ArgumentNullException">dbPath</exception>
public static async Task<IDbConnection> ConnectToDb(string dbPath) public static async Task<IDbConnection> ConnectToDb(string dbPath, ILogger logger)
{ {
if (string.IsNullOrEmpty(dbPath)) if (string.IsNullOrEmpty(dbPath))
{ {
throw new ArgumentNullException("dbPath"); throw new ArgumentNullException("dbPath");
} }
logger.Info("Opening {0}", dbPath);
#if __MonoCS__ #if __MonoCS__
var connectionstr = new SqliteConnectionStringBuilder var connectionstr = new SqliteConnectionStringBuilder
{ {

@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
var chapterDbFile = Path.Combine(_appPaths.DataPath, "chapters.db"); var chapterDbFile = Path.Combine(_appPaths.DataPath, "chapters.db");
var chapterConnection = SqliteExtensions.ConnectToDb(chapterDbFile).Result; var chapterConnection = SqliteExtensions.ConnectToDb(chapterDbFile, _logger).Result;
_chapterRepository = new SqliteChapterRepository(chapterConnection, logManager); _chapterRepository = new SqliteChapterRepository(chapterConnection, logManager);
} }
@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
var dbFile = Path.Combine(_appPaths.DataPath, "library.db"); var dbFile = Path.Combine(_appPaths.DataPath, "library.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = { string[] queries = {

@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db"); var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = { string[] queries = {

@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
var dbFile = Path.Combine(_appPaths.DataPath, "userdata_v2.db"); var dbFile = Path.Combine(_appPaths.DataPath, "userdata_v2.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = { string[] queries = {

@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
var dbFile = Path.Combine(_appPaths.DataPath, "users.db"); var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = { string[] queries = {

@ -1,4 +1,5 @@
using MediaBrowser.Common.IO; using System.Collections.Generic;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
@ -268,7 +269,7 @@ namespace MediaBrowser.Server.Implementations.Providers
{ {
item.ScreenshotImagePaths[imageIndex.Value] = path; item.ScreenshotImagePaths[imageIndex.Value] = path;
} }
else else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
{ {
item.ScreenshotImagePaths.Add(path); item.ScreenshotImagePaths.Add(path);
} }
@ -282,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Providers
{ {
item.BackdropImagePaths[imageIndex.Value] = path; item.BackdropImagePaths[imageIndex.Value] = path;
} }
else else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
{ {
item.BackdropImagePaths.Add(path); item.BackdropImagePaths.Add(path);
} }
@ -333,14 +334,14 @@ namespace MediaBrowser.Server.Implementations.Providers
{ {
throw new ArgumentNullException("imageIndex"); throw new ArgumentNullException("imageIndex");
} }
filename = imageIndex.Value == 0 ? "backdrop" : "backdrop" + imageIndex.Value.ToString(UsCulture); filename = GetBackdropSaveFilename(item.BackdropImagePaths, "backdrop", "backdrop", imageIndex.Value);
break; break;
case ImageType.Screenshot: case ImageType.Screenshot:
if (!imageIndex.HasValue) if (!imageIndex.HasValue)
{ {
throw new ArgumentNullException("imageIndex"); throw new ArgumentNullException("imageIndex");
} }
filename = imageIndex.Value == 0 ? "screenshot" : "screenshot" + imageIndex.Value.ToString(UsCulture); filename = GetBackdropSaveFilename(item.ScreenshotImagePaths, "screenshot", "screenshot", imageIndex.Value);
break; break;
default: default:
filename = type.ToString().ToLower(); filename = type.ToString().ToLower();
@ -380,6 +381,24 @@ namespace MediaBrowser.Server.Implementations.Providers
return path; return path;
} }
private string GetBackdropSaveFilename(List<string> images, string zeroIndexFilename, string numberedIndexPrefix, int index)
{
var filesnames = images.Select(Path.GetFileNameWithoutExtension).ToList();
if (index == 0)
{
return zeroIndexFilename;
}
var current = index;
while (filesnames.Contains(numberedIndexPrefix + current.ToString(UsCulture), StringComparer.OrdinalIgnoreCase))
{
current++;
}
return numberedIndexPrefix + current.ToString(UsCulture);
}
/// <summary> /// <summary>
/// Gets the compatible save paths. /// Gets the compatible save paths.
/// </summary> /// </summary>

@ -34,9 +34,16 @@ namespace MediaBrowser.Server.Implementations.Sorting
} }
if (x.ProductionYear.HasValue) if (x.ProductionYear.HasValue)
{
try
{ {
return new DateTime(x.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc); return new DateTime(x.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc);
} }
catch (ArgumentOutOfRangeException)
{
// Don't blow up if the item has a bad ProductionYear, just return MinValue
}
}
return DateTime.MinValue; return DateTime.MinValue;
} }

Loading…
Cancel
Save