diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-01-05 23:36:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-05 23:36:59 -0500 |
| commit | 0a202a58f888c4d384a70c571e6d05d09b8020b2 (patch) | |
| tree | fd06847cb48887d4bfc1087d70a42ea0e5efb6c9 /Emby.Server.Implementations | |
| parent | 5ff78b5130d0b2712494f4830a9d4f025b09ede3 (diff) | |
| parent | 424c83bda8c44c81eff62a26f4e2e65ceaf6de6f (diff) | |
Merge pull request #2381 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
7 files changed, 60 insertions, 54 deletions
diff --git a/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs b/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs index 170ef07f3..7f15f20cb 100644 --- a/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -9,6 +9,7 @@ using System; using System.IO; using System.Text; using System.Threading.Tasks; +using MediaBrowser.Controller.Security; using MediaBrowser.Model.IO; using MediaBrowser.Model.Threading; @@ -26,8 +27,9 @@ namespace Emby.Server.Implementations.Connect private readonly IApplicationHost _appHost; private readonly IFileSystem _fileSystem; private readonly ITimerFactory _timerFactory; + private readonly IEncryptionManager _encryption; - public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost, IFileSystem fileSystem, ITimerFactory timerFactory) + public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost, IFileSystem fileSystem, ITimerFactory timerFactory, IEncryptionManager encryption) { _httpClient = httpClient; _appPaths = appPaths; @@ -37,6 +39,7 @@ namespace Emby.Server.Implementations.Connect _appHost = appHost; _fileSystem = fileSystem; _timerFactory = timerFactory; + _encryption = encryption; } public void Run() @@ -143,7 +146,7 @@ namespace Emby.Server.Implementations.Connect private string CacheFilePath { - get { return Path.Combine(_appPaths.DataPath, "wan.txt"); } + get { return Path.Combine(_appPaths.DataPath, "wan.dat"); } } private void CacheAddress(IpAddressInfo address) @@ -153,7 +156,14 @@ namespace Emby.Server.Implementations.Connect try { _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - _fileSystem.WriteAllText(path, address.ToString(), Encoding.UTF8); + } + catch (Exception ex) + { + } + + try + { + _fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8); } catch (Exception ex) { @@ -169,7 +179,7 @@ namespace Emby.Server.Implementations.Connect try { - var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8); + var endpoint = _encryption.DecryptString(_fileSystem.ReadAllText(path, Encoding.UTF8)); IpAddressInfo ipAddress; if (_networkManager.TryParseIpAddress(endpoint, out ipAddress)) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 8c16216b9..a6119f155 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -2548,57 +2548,53 @@ namespace Emby.Server.Implementations.Data { using (var connection = CreateConnection(true)) { - return connection.RunInTransaction(db => - { - var list = new List<BaseItem>(); + var list = new List<BaseItem>(); - using (var statement = PrepareStatementSafe(db, commandText)) + using (var statement = PrepareStatementSafe(connection, commandText)) + { + if (EnableJoinUserData(query)) { - if (EnableJoinUserData(query)) - { - statement.TryBind("@UserId", query.User.Id); - } + statement.TryBind("@UserId", query.User.Id); + } - BindSimilarParams(query, statement); + BindSimilarParams(query, statement); - // Running this again will bind the params - GetWhereClauses(query, statement); + // Running this again will bind the params + GetWhereClauses(query, statement); - foreach (var row in statement.ExecuteQuery()) + foreach (var row in statement.ExecuteQuery()) + { + var item = GetItem(row, query); + if (item != null) { - var item = GetItem(row, query); - if (item != null) - { - list.Add(item); - } + list.Add(item); } } + } - // Hack for right now since we currently don't support filtering out these duplicates within a query - if (query.EnableGroupByMetadataKey) + // Hack for right now since we currently don't support filtering out these duplicates within a query + if (query.EnableGroupByMetadataKey) + { + var limit = query.Limit ?? int.MaxValue; + limit -= 4; + var newList = new List<BaseItem>(); + + foreach (var item in list) { - var limit = query.Limit ?? int.MaxValue; - limit -= 4; - var newList = new List<BaseItem>(); + AddItem(newList, item); - foreach (var item in list) + if (newList.Count >= limit) { - AddItem(newList, item); - - if (newList.Count >= limit) - { - break; - } + break; } - - list = newList; } - LogQueryTime("GetItemList", commandText, now); + list = newList; + } - return list; + LogQueryTime("GetItemList", commandText, now); - }, ReadTransactionMode); + return list; } } } diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index e2446b16f..46b914232 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -182,7 +182,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings programsInfo.Add(GetProgram(channelNumber, schedule, programDict[schedule.programID])); } - _logger.Info("Finished with EPGData"); } } @@ -322,8 +321,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings using (var response = await Get(httpOptions, true, info).ConfigureAwait(false)) { var root = _jsonSerializer.DeserializeFromStream<ScheduleDirect.Channel>(response); - _logger.Info("Found " + root.map.Count + " channels on the lineup on ScheduleDirect"); - _logger.Info("Mapping Stations to Channel"); + foreach (ScheduleDirect.Map map in root.map) { var channelNumber = map.logicalChannelNumber; @@ -353,7 +351,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings }); } } - _logger.Info("Added " + GetChannelPairCacheCount(listingsId) + " channels to the dictionary"); foreach (ChannelInfo channel in channels) { diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 77efe8585..c2abf1d34 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -103,7 +103,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun TunerHostId = info.Id, IsHD = i.HD == 1, AudioCodec = i.AudioCodec, - VideoCodec = i.VideoCodec + VideoCodec = i.VideoCodec, + ChannelType = ChannelType.TV }); } diff --git a/Emby.Server.Implementations/Sync/SyncHelper.cs b/Emby.Server.Implementations/Sync/SyncHelper.cs index da475f003..7fe703796 100644 --- a/Emby.Server.Implementations/Sync/SyncHelper.cs +++ b/Emby.Server.Implementations/Sync/SyncHelper.cs @@ -4,7 +4,7 @@ namespace Emby.Server.Implementations.Sync { public class SyncHelper { - public static int? AdjustBitrate(int? profileBitrate, string quality) + public static long? AdjustBitrate(long? profileBitrate, string quality) { if (profileBitrate.HasValue) { diff --git a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs b/Emby.Server.Implementations/Sync/SyncJobProcessor.cs index b1adc64df..17cdef5fc 100644 --- a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/Emby.Server.Implementations/Sync/SyncJobProcessor.cs @@ -59,15 +59,8 @@ namespace Emby.Server.Implementations.Sync _mediaSourceManager = mediaSourceManager; } - public async Task EnsureJobItems(SyncJob job) + public async Task EnsureJobItems(SyncJob job, User user) { - var user = _userManager.GetUserById(job.UserId); - - if (user == null) - { - throw new InvalidOperationException("Cannot proceed with sync because user no longer exists."); - } - var items = (await GetItemsForSync(job.Category, job.ParentId, job.RequestedItemIds, user, job.UnwatchedOnly).ConfigureAwait(false)) .ToList(); @@ -385,7 +378,16 @@ namespace Emby.Server.Implementations.Sync if (job.SyncNewContent) { - await EnsureJobItems(job).ConfigureAwait(false); + var user = _userManager.GetUserById(job.UserId); + + if (user == null) + { + await _syncManager.CancelJob(job.Id).ConfigureAwait(false); + } + else + { + await EnsureJobItems(job, user).ConfigureAwait(false); + } } } } diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index 310b35afe..2687eaefc 100644 --- a/Emby.Server.Implementations/Sync/SyncManager.cs +++ b/Emby.Server.Implementations/Sync/SyncManager.cs @@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Sync await _repo.Create(job).ConfigureAwait(false); - await processor.EnsureJobItems(job).ConfigureAwait(false); + await processor.EnsureJobItems(job, user).ConfigureAwait(false); // If it already has a converting status then is must have been aborted during conversion var jobItemsResult = GetJobItems(new SyncJobItemQuery |
