mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
add db startup error handling
This commit is contained in:
@@ -818,30 +818,6 @@ namespace Emby.Server.Implementations.Library
|
||||
return _userRootFolder;
|
||||
}
|
||||
|
||||
public Guid? FindIdByPath(string path, bool? isFolder)
|
||||
{
|
||||
// If this returns multiple items it could be tricky figuring out which one is correct.
|
||||
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
|
||||
|
||||
var query = new InternalItemsQuery
|
||||
{
|
||||
Path = path,
|
||||
IsFolder = isFolder,
|
||||
SortBy = new[] { ItemSortBy.DateCreated },
|
||||
SortOrder = SortOrder.Descending,
|
||||
Limit = 1
|
||||
};
|
||||
|
||||
var id = GetItemIds(query);
|
||||
|
||||
if (id.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return id[0];
|
||||
}
|
||||
|
||||
public BaseItem FindByPath(string path, bool? isFolder)
|
||||
{
|
||||
// If this returns multiple items it could be tricky figuring out which one is correct.
|
||||
|
||||
@@ -248,6 +248,13 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
var isPlayed = request.IsPlayed;
|
||||
|
||||
if (parents.OfType<ICollectionFolder>().Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
isPlayed = null;
|
||||
}
|
||||
|
||||
if (parents.Count == 0)
|
||||
{
|
||||
parents = user.RootFolder.GetChildren(user, true)
|
||||
@@ -282,7 +289,7 @@ namespace Emby.Server.Implementations.Library
|
||||
IsVirtualItem = false,
|
||||
Limit = limit * 5,
|
||||
SourceTypes = parents.Count == 0 ? new[] { SourceType.Library } : new SourceType[] { },
|
||||
IsPlayed = request.IsPlayed
|
||||
IsPlayed = isPlayed
|
||||
|
||||
}, parents);
|
||||
}
|
||||
|
||||
@@ -1172,7 +1172,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
};
|
||||
|
||||
var isAudio = false;
|
||||
await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, false, cancellationToken).ConfigureAwait(false);
|
||||
await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new List<MediaSourceInfo>
|
||||
{
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
_logger.Info("Calling recording process.WaitForExit for {0}", _targetPath);
|
||||
|
||||
if (_process.WaitForExit(5000))
|
||||
if (_process.WaitForExit(10000))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, bool assumeInterlaced, CancellationToken cancellationToken)
|
||||
public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
|
||||
{
|
||||
var originalRuntime = mediaSource.RunTimeTicks;
|
||||
|
||||
@@ -96,17 +96,6 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
videoStream.IsAVC = null;
|
||||
}
|
||||
|
||||
if (assumeInterlaced)
|
||||
{
|
||||
foreach (var mediaStream in mediaSource.MediaStreams)
|
||||
{
|
||||
if (mediaStream.Type == MediaStreamType.Video)
|
||||
{
|
||||
mediaStream.IsInterlaced = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to estimate this
|
||||
mediaSource.InferTotalBitrate(true);
|
||||
}
|
||||
|
||||
@@ -126,14 +126,12 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
var keys = openToken.Split(new[] { StreamIdDelimeter }, 3);
|
||||
var mediaSourceId = keys.Length >= 3 ? keys[2] : null;
|
||||
IDirectStreamProvider directStreamProvider = null;
|
||||
var assumeInterlaced = false;
|
||||
|
||||
if (string.Equals(keys[0], typeof(LiveTvChannel).Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var info = await _liveTvManager.GetChannelStream(keys[1], mediaSourceId, cancellationToken).ConfigureAwait(false);
|
||||
stream = info.Item1;
|
||||
directStreamProvider = info.Item2;
|
||||
assumeInterlaced = info.Item3;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,7 +146,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
}
|
||||
else
|
||||
{
|
||||
await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, assumeInterlaced, cancellationToken).ConfigureAwait(false);
|
||||
await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Emby.Server.Implementations.Data;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Notifications;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using SQLitePCL.pretty;
|
||||
@@ -16,8 +17,11 @@ namespace Emby.Server.Implementations.Notifications
|
||||
{
|
||||
public class SqliteNotificationsRepository : BaseSqliteRepository, INotificationsRepository
|
||||
{
|
||||
public SqliteNotificationsRepository(ILogger logger, IServerApplicationPaths appPaths) : base(logger)
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
|
||||
public SqliteNotificationsRepository(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem) : base(logger)
|
||||
{
|
||||
FileSystem = fileSystem;
|
||||
DbFilePath = Path.Combine(appPaths.DataPath, "notifications.db");
|
||||
}
|
||||
|
||||
@@ -26,6 +30,22 @@ namespace Emby.Server.Implementations.Notifications
|
||||
////public event EventHandler<NotificationUpdateEventArgs> NotificationUpdated;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeInternal();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error loading notifications database file. Will reset and retry.", ex);
|
||||
|
||||
FileSystem.DeleteFile(DbFilePath);
|
||||
|
||||
InitializeInternal();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeInternal()
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user