mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-30 04:34:49 +03:00
Reduce the amount of exceptions thrown
This commit is contained in:
@@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.Diagnostics
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_process.Dispose();
|
||||
_process?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
if (item is IItemByName)
|
||||
{
|
||||
if (!(item is MusicArtist))
|
||||
@@ -285,18 +286,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (item.IsFolder)
|
||||
{
|
||||
//if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel) && !(item is AggregateFolder))
|
||||
//{
|
||||
// if (item.SourceType != SourceType.Library)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else
|
||||
else if (!item.IsFolder)
|
||||
{
|
||||
if (!(item is Video) && !(item is LiveTvChannel))
|
||||
{
|
||||
@@ -371,19 +361,20 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
foreach (var metadataPath in GetMetadataPaths(item, children))
|
||||
{
|
||||
_logger.LogDebug("Deleting path {0}", metadataPath);
|
||||
if (!Directory.Exists(metadataPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Deleting path {MetadataPath}", metadataPath);
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(metadataPath, true);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error deleting {metadataPath}", metadataPath);
|
||||
_logger.LogError(ex, "Error deleting {MetadataPath}", metadataPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_streamHelper = streamHelper;
|
||||
|
||||
_seriesTimerProvider = new SeriesTimerManager(jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
|
||||
_timerProvider = new TimerManager(jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger);
|
||||
_seriesTimerProvider = new SeriesTimerManager(jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers.json"));
|
||||
_timerProvider = new TimerManager(jsonSerializer, _logger, Path.Combine(DataPath, "timers.json"), _logger);
|
||||
_timerProvider.TimerFired += _timerProvider_TimerFired;
|
||||
|
||||
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -32,32 +31,28 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
if (_items == null)
|
||||
{
|
||||
if (!File.Exists(_dataPath))
|
||||
{
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
Logger.LogInformation("Loading live tv data from {0}", _dataPath);
|
||||
_items = GetItemsFromFile(_dataPath);
|
||||
}
|
||||
|
||||
return _items.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<T> GetItemsFromFile(string path)
|
||||
{
|
||||
var jsonFile = path + ".json";
|
||||
|
||||
if (!File.Exists(jsonFile))
|
||||
{
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return _jsonSerializer.DeserializeFromFile<List<T>>(jsonFile) ?? new List<T>();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return _jsonSerializer.DeserializeFromFile<List<T>>(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error deserializing {jsonFile}", jsonFile);
|
||||
Logger.LogError(ex, "Error deserializing {Path}", path);
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
@@ -70,12 +65,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
throw new ArgumentNullException(nameof(newList));
|
||||
}
|
||||
|
||||
var file = _dataPath + ".json";
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_dataPath));
|
||||
|
||||
lock (_fileDataLock)
|
||||
{
|
||||
_jsonSerializer.SerializeToFile(newList, file);
|
||||
_jsonSerializer.SerializeToFile(newList, _dataPath);
|
||||
_items = newList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,10 @@ namespace Emby.Server.Implementations.MediaEncoder
|
||||
private static List<string> GetSavedChapterImages(Video video, IDirectoryService directoryService)
|
||||
{
|
||||
var path = GetChapterImagesPath(video);
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user