move classes to portable project

This commit is contained in:
Luke Pulverenti 2016-11-03 18:34:16 -04:00
parent 1d62a88fd8
commit f52373609e
27 changed files with 89 additions and 71 deletions

View File

@ -35,5 +35,13 @@ namespace Emby.Common.Implementations.Cryptography
return provider.ComputeHash(str);
}
}
public byte[] GetMD5Bytes(byte[] bytes)
{
using (var provider = MD5.Create())
{
return provider.ComputeHash(bytes);
}
}
}
}

View File

@ -1,14 +1,18 @@
using System;
using System.IO;
using MediaBrowser.Model.Reflection;
using System.Reflection;
namespace MediaBrowser.Server.Implementations.Reflection
namespace Emby.Common.Implementations.Reflection
{
public class AssemblyInfo : IAssemblyInfo
{
public Stream GetManifestResourceStream(Type type, string resource)
{
#if NET46
return type.Assembly.GetManifestResourceStream(resource);
#endif
return type.GetTypeInfo().Assembly.GetManifestResourceStream(resource);
}
}
}

View File

@ -2,7 +2,7 @@
using MediaBrowser.Model.IO;
using MediaBrowser.Model.TextEncoding;
namespace MediaBrowser.Server.Implementations.TextEncoding
namespace Emby.Common.Implementations.TextEncoding
{
public class TextEncoding : IEncoding
{
@ -42,8 +42,7 @@ namespace MediaBrowser.Server.Implementations.TextEncoding
if (buffer[0] == 0x2b && buffer[1] == 0x2f && buffer[2] == 0x76)
return Encoding.UTF7;
// It's ok - anything aside from utf is ok since that's what we're looking for
return Encoding.Default;
return null;
}
}
}

View File

@ -1,7 +1,7 @@
using System.Xml;
using MediaBrowser.Model.Xml;
namespace MediaBrowser.Server.Implementations.Xml
namespace Emby.Common.Implementations.Xml
{
public class XmlReaderSettingsFactory : IXmlReaderSettingsFactory
{
@ -11,7 +11,9 @@ namespace MediaBrowser.Server.Implementations.Xml
if (!enableValidation)
{
#if NET46
settings.ValidationType = ValidationType.None;
#endif
}
return settings;

View File

@ -69,6 +69,7 @@
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
<Compile Include="Images\BaseDynamicImageProvider.cs" />
<Compile Include="Intros\DefaultIntroProvider.cs" />
<Compile Include="IO\ThrottledStream.cs" />
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
<Compile Include="Library\LibraryManager.cs" />
<Compile Include="Library\LocalTrailerPostScanTask.cs" />
@ -161,14 +162,28 @@
<Compile Include="Sorting\SortNameComparer.cs" />
<Compile Include="Sorting\StartDateComparer.cs" />
<Compile Include="Sorting\StudioComparer.cs" />
<Compile Include="Sync\AppSyncProvider.cs" />
<Compile Include="Sync\CloudSyncProfile.cs" />
<Compile Include="Sync\IHasSyncQuality.cs" />
<Compile Include="Sync\MediaSync.cs" />
<Compile Include="Sync\MultiProviderSync.cs" />
<Compile Include="Sync\ServerSyncScheduledTask.cs" />
<Compile Include="Sync\SyncConfig.cs" />
<Compile Include="Sync\SyncConvertScheduledTask.cs" />
<Compile Include="Sync\SyncedMediaSourceProvider.cs" />
<Compile Include="Sync\SyncHelper.cs" />
<Compile Include="Sync\SyncJobOptions.cs" />
<Compile Include="Sync\SyncJobProcessor.cs" />
<Compile Include="Sync\SyncManager.cs" />
<Compile Include="Sync\SyncNotificationEntryPoint.cs" />
<Compile Include="Sync\SyncRegistrationInfo.cs" />
<Compile Include="Sync\TargetDataProvider.cs" />
<Compile Include="TV\TVSeriesManager.cs" />
<Compile Include="Updates\InstallationManager.cs" />
<Compile Include="UserViews\CollectionFolderImageProvider.cs" />
<Compile Include="UserViews\DynamicImageProvider.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="IO\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>

View File

@ -3,7 +3,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.IO
namespace Emby.Server.Implementations.IO
{
/// <summary>
/// Class for streaming data with throttling support.
@ -326,9 +326,10 @@ namespace MediaBrowser.Server.Implementations.IO
try
{
// The time to sleep is more then a millisecond, so sleep.
Thread.Sleep(toSleep);
var task = Task.Delay(toSleep);
Task.WaitAll(task);
}
catch (ThreadAbortException)
catch
{
// Eatup ThreadAbortException.
}

View File

@ -7,7 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncQuality, IHasDuplicateCheck
{

View File

@ -1,7 +1,7 @@
using MediaBrowser.Model.Dlna;
using System.Collections.Generic;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class CloudSyncProfile : DeviceProfile
{

View File

@ -1,7 +1,7 @@
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public interface IHasSyncQuality
{

View File

@ -13,15 +13,14 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.IO;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Server.Implementations.IO;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class MediaSync
{
@ -30,17 +29,19 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
private readonly IConfigurationManager _config;
private readonly ICryptographyProvider _cryptographyProvider;
public const string PathSeparatorString = "/";
public const char PathSeparatorChar = '/';
public MediaSync(ILogger logger, ISyncManager syncManager, IServerApplicationHost appHost, IFileSystem fileSystem, IConfigurationManager config)
public MediaSync(ILogger logger, ISyncManager syncManager, IServerApplicationHost appHost, IFileSystem fileSystem, IConfigurationManager config, ICryptographyProvider cryptographyProvider)
{
_logger = logger;
_syncManager = syncManager;
_appHost = appHost;
_fileSystem = fileSystem;
_config = config;
_cryptographyProvider = cryptographyProvider;
}
public async Task Sync(IServerSyncProvider provider,
@ -360,19 +361,16 @@ namespace MediaBrowser.Server.Implementations.Sync
}
}
private static string GetLocalId(string jobItemId, string itemId)
private string GetLocalId(string jobItemId, string itemId)
{
var bytes = Encoding.UTF8.GetBytes(jobItemId + itemId);
bytes = CreateMd5(bytes);
return BitConverter.ToString(bytes, 0, bytes.Length).Replace("-", string.Empty);
}
private static byte[] CreateMd5(byte[] value)
private byte[] CreateMd5(byte[] value)
{
using (var provider = MD5.Create())
{
return provider.ComputeHash(value);
}
return _cryptographyProvider.GetMD5Bytes(value);
}
public LocalItem CreateLocalItem(IServerSyncProvider provider, SyncedItem syncedItem, SyncJob job, SyncTarget target, BaseItemDto libraryItem, string serverId, string serverName, string originalFileName)

View File

@ -11,9 +11,10 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class MultiProviderSync
{
@ -22,14 +23,16 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
private readonly IConfigurationManager _config;
private readonly ICryptographyProvider _cryptographyProvider;
public MultiProviderSync(SyncManager syncManager, IServerApplicationHost appHost, ILogger logger, IFileSystem fileSystem, IConfigurationManager config)
public MultiProviderSync(SyncManager syncManager, IServerApplicationHost appHost, ILogger logger, IFileSystem fileSystem, IConfigurationManager config, ICryptographyProvider cryptographyProvider)
{
_syncManager = syncManager;
_appHost = appHost;
_logger = logger;
_fileSystem = fileSystem;
_config = config;
_cryptographyProvider = cryptographyProvider;
}
public async Task Sync(IEnumerable<IServerSyncProvider> providers, IProgress<double> progress, CancellationToken cancellationToken)
@ -61,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var dataProvider = _syncManager.GetDataProvider(target.Item1, target.Item2);
await new MediaSync(_logger, _syncManager, _appHost, _fileSystem, _config)
await new MediaSync(_logger, _syncManager, _appHost, _fileSystem, _config, _cryptographyProvider)
.Sync(target.Item1, dataProvider, target.Item2, innerProgress, cancellationToken)
.ConfigureAwait(false);

View File

@ -7,10 +7,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
class ServerSyncScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
@ -19,14 +20,16 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly IFileSystem _fileSystem;
private readonly IServerApplicationHost _appHost;
private readonly IConfigurationManager _config;
private readonly ICryptographyProvider _cryptographyProvider;
public ServerSyncScheduledTask(ISyncManager syncManager, ILogger logger, IFileSystem fileSystem, IServerApplicationHost appHost, IConfigurationManager config)
public ServerSyncScheduledTask(ISyncManager syncManager, ILogger logger, IFileSystem fileSystem, IServerApplicationHost appHost, IConfigurationManager config, ICryptographyProvider cryptographyProvider)
{
_syncManager = syncManager;
_logger = logger;
_fileSystem = fileSystem;
_appHost = appHost;
_config = config;
_cryptographyProvider = cryptographyProvider;
}
public string Name
@ -49,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{
return new MultiProviderSync((SyncManager)_syncManager, _appHost, _logger, _fileSystem, _config)
return new MultiProviderSync((SyncManager)_syncManager, _appHost, _logger, _fileSystem, _config, _cryptographyProvider)
.Sync(ServerSyncProviders, progress, cancellationToken);
}

View File

@ -2,7 +2,7 @@
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncConfigurationFactory : IConfigurationFactory
{

View File

@ -13,7 +13,7 @@ using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncConvertScheduledTask : IScheduledTask
{

View File

@ -1,6 +1,6 @@
using System;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncHelper
{

View File

@ -1,6 +1,6 @@
using MediaBrowser.Model.Dlna;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncJobOptions
{

View File

@ -28,7 +28,7 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncJobProcessor
{

View File

@ -23,6 +23,7 @@ using MediaBrowser.Model.Users;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
@ -30,7 +31,7 @@ using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncManager : ISyncManager
{
@ -124,7 +125,7 @@ namespace MediaBrowser.Server.Implementations.Sync
if (string.IsNullOrWhiteSpace(request.Name))
{
request.Name = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
request.Name = DateTime.Now.ToString("f1", CultureInfo.CurrentCulture);
}
var target = GetSyncTargets(request.UserId)
@ -419,7 +420,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
_fileSystem.DeleteDirectory(path, true);
}
catch (DirectoryNotFoundException)
catch (IOException)
{
}
@ -574,7 +575,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
_fileSystem.DeleteDirectory(jobItem.TemporaryPath, true);
}
catch (DirectoryNotFoundException)
catch (IOException)
{
}
catch (Exception ex)
@ -1061,7 +1062,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
_fileSystem.DeleteDirectory(path, true);
}
catch (DirectoryNotFoundException)
catch (IOException)
{
}

View File

@ -5,7 +5,7 @@ using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Sync;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncNotificationEntryPoint : IServerEntryPoint
{

View File

@ -1,7 +1,7 @@
using MediaBrowser.Common.Security;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncRegistrationInfo : IRequiresRegistration
{

View File

@ -12,7 +12,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class SyncedMediaSourceProvider : IMediaSourceProvider
{
@ -144,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
mediaSource.Id = item.Id;
mediaSource.SupportsTranscoding = false;
if (mediaSource.Protocol == Model.MediaInfo.MediaProtocol.File)
if (mediaSource.Protocol == MediaBrowser.Model.MediaInfo.MediaProtocol.File)
{
mediaSource.ETag = item.Id;
}

View File

@ -11,7 +11,7 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Sync
namespace Emby.Server.Implementations.Sync
{
public class TargetDataProvider : ISyncDataProvider
{

View File

@ -793,7 +793,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
if (protocol == MediaProtocol.File)
{
if (_textEncoding.GetFileEncoding(path).Equals(Encoding.UTF8))
var fileEncoding = _textEncoding.GetFileEncoding(path);
if (fileEncoding != null && fileEncoding.Equals(Encoding.UTF8))
{
return string.Empty;
}

View File

@ -9,5 +9,6 @@ namespace MediaBrowser.Model.Cryptography
byte[] GetMD5Bytes(string str);
byte[] GetSHA1Bytes(byte[] bytes);
byte[] GetMD5Bytes(Stream str);
byte[] GetMD5Bytes(byte[] bytes);
}
}

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
using Microsoft.Win32;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -17,6 +16,7 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Threading;
using Microsoft.Win32;
namespace MediaBrowser.Server.Implementations.IO
{

View File

@ -144,7 +144,6 @@
<Compile Include="IO\FileRefresher.cs" />
<Compile Include="IO\LibraryMonitor.cs" />
<Compile Include="IO\MemoryStreamProvider.cs" />
<Compile Include="IO\ThrottledStream.cs" />
<Compile Include="LiveTv\ChannelImageProvider.cs" />
<Compile Include="LiveTv\EmbyTV\DirectRecorder.cs" />
<Compile Include="LiveTv\EmbyTV\EmbyTV.cs" />
@ -202,17 +201,12 @@
<Compile Include="Persistence\DataExtensions.cs" />
<Compile Include="Persistence\IDbConnector.cs" />
<Compile Include="Persistence\MediaStreamColumns.cs" />
<Compile Include="Reflection\AssemblyInfo.cs" />
<Compile Include="Security\MBLicenseFile.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Security\RegRecord.cs" />
<Compile Include="Serialization\JsonSerializer.cs" />
<Compile Include="Social\SharingManager.cs" />
<Compile Include="Social\SharingRepository.cs" />
<Compile Include="Sync\SyncHelper.cs" />
<Compile Include="Sync\SyncJobOptions.cs" />
<Compile Include="Sync\SyncNotificationEntryPoint.cs" />
<Compile Include="TextEncoding\TextEncoding.cs" />
<Compile Include="Threading\PeriodicTimer.cs" />
<Compile Include="TV\SeriesPostScanTask.cs" />
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
@ -235,23 +229,9 @@
<Compile Include="Persistence\SqliteItemRepository.cs" />
<Compile Include="Persistence\SqliteUserDataRepository.cs" />
<Compile Include="Persistence\SqliteUserRepository.cs" />
<Compile Include="Sync\AppSyncProvider.cs" />
<Compile Include="Sync\CloudSyncProfile.cs" />
<Compile Include="Sync\IHasSyncQuality.cs" />
<Compile Include="Sync\MediaSync.cs" />
<Compile Include="Sync\MultiProviderSync.cs" />
<Compile Include="Sync\ServerSyncScheduledTask.cs" />
<Compile Include="Sync\SyncedMediaSourceProvider.cs" />
<Compile Include="Sync\SyncRegistrationInfo.cs" />
<Compile Include="Sync\SyncConfig.cs" />
<Compile Include="Sync\SyncJobProcessor.cs" />
<Compile Include="Sync\SyncManager.cs" />
<Compile Include="Sync\SyncRepository.cs" />
<Compile Include="Sync\SyncConvertScheduledTask.cs" />
<Compile Include="Sync\TargetDataProvider.cs" />
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
<Compile Include="Udp\UdpServer.cs" />
<Compile Include="Xml\XmlReaderSettingsFactory.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">

View File

@ -83,7 +83,10 @@ using System.Threading;
using System.Threading.Tasks;
using Emby.Common.Implementations;
using Emby.Common.Implementations.Networking;
using Emby.Common.Implementations.Reflection;
using Emby.Common.Implementations.TextEncoding;
using Emby.Common.Implementations.Updates;
using Emby.Common.Implementations.Xml;
using Emby.Photos;
using MediaBrowser.Model.IO;
using MediaBrowser.Api.Playback;
@ -110,6 +113,7 @@ using Emby.Server.Implementations.MediaEncoder;
using Emby.Server.Implementations.Notifications;
using Emby.Server.Implementations.Persistence;
using Emby.Server.Implementations.Playlists;
using Emby.Server.Implementations.Sync;
using Emby.Server.Implementations.TV;
using Emby.Server.Implementations.Updates;
using MediaBrowser.Model.Activity;
@ -124,10 +128,7 @@ using MediaBrowser.Model.Social;
using MediaBrowser.Model.TextEncoding;
using MediaBrowser.Model.Xml;
using MediaBrowser.Server.Implementations.Archiving;
using MediaBrowser.Server.Implementations.Reflection;
using MediaBrowser.Server.Implementations.Serialization;
using MediaBrowser.Server.Implementations.TextEncoding;
using MediaBrowser.Server.Implementations.Xml;
using OpenSubtitlesHandler;
using ServiceStack;
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;