fix library scan stopping and restarting itself
This commit is contained in:
parent
ab490d7467
commit
ed34b67f51
|
@ -275,7 +275,10 @@ namespace MediaBrowser.Model.Configuration
|
|||
MetadataCountryCode = "US";
|
||||
DownloadMovieImages = new ImageDownloadOptions();
|
||||
DownloadSeriesImages = new ImageDownloadOptions();
|
||||
DownloadSeasonImages = new ImageDownloadOptions();
|
||||
DownloadSeasonImages = new ImageDownloadOptions
|
||||
{
|
||||
Backdrops = false
|
||||
};
|
||||
DownloadMusicArtistImages = new ImageDownloadOptions();
|
||||
DownloadMusicAlbumImages = new ImageDownloadOptions();
|
||||
MaxBackdrops = 3;
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
!imagesFileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(imagesFileInfo) > providerInfo.LastRefreshed;
|
||||
}
|
||||
|
||||
return true;
|
||||
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -562,8 +562,8 @@ namespace MediaBrowser.Providers.Savers
|
|||
{
|
||||
var timespan = TimeSpan.FromTicks(item.RunTimeTicks.Value);
|
||||
|
||||
builder.Append("<Duration>" + Convert.ToInt32(timespan.TotalMinutes).ToString(UsCulture) + "</Duration>");
|
||||
builder.Append("<DurationSeconds>" + Convert.ToInt32(timespan.TotalSeconds).ToString(UsCulture) + "</DurationSeconds>");
|
||||
builder.Append("<Duration>" + Convert.ToInt64(timespan.TotalMinutes).ToString(UsCulture) + "</Duration>");
|
||||
builder.Append("<DurationSeconds>" + Convert.ToInt64(timespan.TotalSeconds).ToString(UsCulture) + "</DurationSeconds>");
|
||||
}
|
||||
|
||||
if (video != null && video.Video3DFormat.HasValue)
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.TV
|
|||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -361,7 +361,33 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
if (e.ChangeType == WatcherChangeTypes.Changed)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
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 = {
|
||||
|
||||
|
|
|
@ -128,15 +128,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
/// Connects to db.
|
||||
/// </summary>
|
||||
/// <param name="dbPath">The db path.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>Task{IDbConnection}.</returns>
|
||||
/// <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))
|
||||
{
|
||||
throw new ArgumentNullException("dbPath");
|
||||
}
|
||||
|
||||
logger.Info("Opening {0}", dbPath);
|
||||
|
||||
#if __MonoCS__
|
||||
var connectionstr = new SqliteConnectionStringBuilder
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
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 = {
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
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 = {
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
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 = {
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
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 = {
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
|
@ -268,7 +269,7 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
{
|
||||
item.ScreenshotImagePaths[imageIndex.Value] = path;
|
||||
}
|
||||
else
|
||||
else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
item.ScreenshotImagePaths.Add(path);
|
||||
}
|
||||
|
@ -282,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
{
|
||||
item.BackdropImagePaths[imageIndex.Value] = path;
|
||||
}
|
||||
else
|
||||
else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
item.BackdropImagePaths.Add(path);
|
||||
}
|
||||
|
@ -333,14 +334,14 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
{
|
||||
throw new ArgumentNullException("imageIndex");
|
||||
}
|
||||
filename = imageIndex.Value == 0 ? "backdrop" : "backdrop" + imageIndex.Value.ToString(UsCulture);
|
||||
filename = GetBackdropSaveFilename(item.BackdropImagePaths, "backdrop", "backdrop", imageIndex.Value);
|
||||
break;
|
||||
case ImageType.Screenshot:
|
||||
if (!imageIndex.HasValue)
|
||||
{
|
||||
throw new ArgumentNullException("imageIndex");
|
||||
}
|
||||
filename = imageIndex.Value == 0 ? "screenshot" : "screenshot" + imageIndex.Value.ToString(UsCulture);
|
||||
filename = GetBackdropSaveFilename(item.ScreenshotImagePaths, "screenshot", "screenshot", imageIndex.Value);
|
||||
break;
|
||||
default:
|
||||
filename = type.ToString().ToLower();
|
||||
|
@ -380,6 +381,24 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
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>
|
||||
/// Gets the compatible save paths.
|
||||
/// </summary>
|
||||
|
|
|
@ -35,7 +35,14 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
|||
|
||||
if (x.ProductionYear.HasValue)
|
||||
{
|
||||
return new DateTime(x.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user