Skip to content

Commit

Permalink
Merge pull request #3237 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored Apr 15, 2018
2 parents c35a06f + 960fe8d commit 1142dd1
Show file tree
Hide file tree
Showing 158 changed files with 730 additions and 1,222 deletions.
2 changes: 1 addition & 1 deletion Emby.Dlna/ContentDirectory/ControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private QueryResult<ServerItem> GetUserItems(BaseItem item, StubType? stubType,
StartIndex = startIndex,
User = user,
IsVirtualItem = false,
PresetViews = new string[] { },
PresetViews = Array.Empty<string>(),
ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name },
IsPlaceHolder = false,
DtoOptions = GetDtoOptions()
Expand Down
19 changes: 15 additions & 4 deletions Emby.Dlna/Emby.Dlna.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
<AssemblyName>Emby.Dlna</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -175,10 +174,22 @@
<EmbeddedResource Include="Profiles\Xml\WDTV Live.xml" />
<EmbeddedResource Include="Profiles\Xml\Xbox One.xml" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Profiles\Xml\Marantz.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
42 changes: 34 additions & 8 deletions Emby.Server.Implementations/ApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
using MediaBrowser.Controller.Authentication;
using System.Diagnostics;

namespace Emby.Server.Implementations
{
Expand Down Expand Up @@ -1000,7 +1001,7 @@ protected void RegisterResources()
var newsService = new Emby.Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
RegisterSingleInstance<INewsService>(newsService);

MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
MediaSourceManager = new MediaSourceManager(ItemRepository, LocalizationManager, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
RegisterSingleInstance(MediaSourceManager);

SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager);
Expand Down Expand Up @@ -1867,18 +1868,43 @@ private void CopyPlugins(string source, string target)
return;
}

Directory.CreateDirectory(target);

foreach (var file in files)
foreach (var sourceFile in files)
{
var filename = Path.GetFileName(file);
var filename = Path.GetFileName(sourceFile);
var targetFile = Path.Combine(target, filename);

if (!ServerConfigurationManager.Configuration.UninstalledPlugins.Contains(filename, StringComparer.OrdinalIgnoreCase) ||
File.Exists(targetFile))
var targetFileExists = File.Exists(targetFile);

if (!targetFileExists && ServerConfigurationManager.Configuration.UninstalledPlugins.Contains(filename, StringComparer.OrdinalIgnoreCase))
{
File.Copy(file, targetFile, true);
continue;
}

if (targetFileExists && GetDllVersion(targetFile) >= GetDllVersion(sourceFile))
{
continue;
}

Directory.CreateDirectory(target);
File.Copy(sourceFile, targetFile, true);
}
}

private Version GetDllVersion(string path)
{
try
{
var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);

Logger.Info("File {0} has version {1}", path, result);

return result;
}
catch (Exception ex)
{
Logger.ErrorException("Error getting version number from {0}", ex, path);

return new Version(1, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Channels/ChannelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public async Task<QueryResult<BaseItem>> GetChannelItemsInternal(InternalItemsQu
{
query.Parent = channel;
}
query.ChannelIds = new Guid[] { };
query.ChannelIds = Array.Empty<Guid>();

// Not yet sure why this is causing a problem
query.GroupByPresentationUniqueKey = false;
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Collections/CollectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ internal async Task<Folder> EnsureLibraryFolder(string path, string name)
return existingFolders[0];
}

_fileSystem.CreateDirectory(path);

var libraryOptions = new LibraryOptions
{
PathInfos = new[] { new MediaPathInfo { Path = path } },
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3712,7 +3712,7 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem

if (!string.IsNullOrWhiteSpace(query.Path))
{
whereClauses.Add("Path=@Path");
whereClauses.Add("(Path=@Path COLLATE NOCASE)");
if (statement != null)
{
statement.TryBind("@Path", query.Path);
Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/Devices/DeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ internal Task EnsureLibraryFolder(string path, string name)
return Task.CompletedTask;
}

_fileSystem.CreateDirectory(path);

var libraryOptions = new LibraryOptions
{
PathInfos = new[] { new MediaPathInfo { Path = path } },
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, D

if (dto.Taglines == null)
{
dto.Taglines = new string[] { };
dto.Taglines = Array.Empty<string>();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
<Compile Include="Library\LibraryManager.cs" />
<Compile Include="Library\LocalTrailerPostScanTask.cs" />
<Compile Include="Library\MediaSourceManager.cs" />
<Compile Include="Library\MediaStreamSelector.cs" />
<Compile Include="Library\MusicManager.cs" />
<Compile Include="Library\PathExtensions.cs" />
<Compile Include="Library\ResolverHelper.cs" />
Expand Down Expand Up @@ -620,8 +621,8 @@
<Project>{1d74413b-e7cf-455b-b021-f52bdf881542}</Project>
<Name>SocketHttpListener</Name>
</ProjectReference>
<Reference Include="Emby.Naming, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaBrowser.Naming.1.1.1\lib\netstandard1.3\Emby.Naming.dll</HintPath>
<Reference Include="Emby.Naming, Version=1.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaBrowser.Naming.1.1.4\lib\netstandard1.3\Emby.Naming.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.MediaEncoding">
<HintPath>..\ThirdParty\emby\Emby.Server.MediaEncoding.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private void Start()
{
_natManager = new NatManager(_logger, _httpClient);
_natManager.DeviceFound += NatUtility_DeviceFound;
_natManager.DeviceLost += NatUtility_DeviceLost;
_natManager.StartDiscovery();
}

Expand Down Expand Up @@ -277,12 +276,6 @@ private Task CreatePortMap(INatDevice device, int privatePort, int publicPort)
});
}

void NatUtility_DeviceLost(object sender, DeviceEventArgs e)
{
var device = e.Device;
_logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString());
}

private bool _disposed = false;
public void Dispose()
{
Expand Down Expand Up @@ -314,7 +307,6 @@ private void DisposeNat()
{
natManager.StopDiscovery();
natManager.DeviceFound -= NatUtility_DeviceFound;
natManager.DeviceLost -= NatUtility_DeviceLost;
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ private async void SendChangeNotifications(List<BaseItem> itemsAdded, List<BaseI
return;
}

if (info.IsEmpty)
{
continue;
}

var userIdString = userId.ToString("N");

try
Expand Down
10 changes: 5 additions & 5 deletions Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public object GetRedirectResult(string url)
var responseHeaders = new Dictionary<string, string>();
responseHeaders["Location"] = url;

var result = new HttpResult(new byte[] { }, "text/plain", HttpStatusCode.Redirect);
var result = new HttpResult(Array.Empty<byte>(), "text/plain", HttpStatusCode.Redirect);

AddResponseHeaders(result, responseHeaders);

Expand Down Expand Up @@ -229,7 +229,7 @@ private object ToOptimizedResultInternal<T>(IRequest request, T dto, IDictionary

if (isHeadRequest)
{
return GetHttpResult(request, new byte[] { }, contentType, true, responseHeaders);
return GetHttpResult(request, Array.Empty<byte>(), contentType, true, responseHeaders);
}

return GetHttpResult(request, ms, contentType, true, responseHeaders);
Expand Down Expand Up @@ -258,7 +258,7 @@ private IHasHeaders GetCompressedResult(byte[] content,

if (isHeadRequest)
{
var result = new StreamWriter(new byte[] { }, contentType, _logger);
var result = new StreamWriter(Array.Empty<byte>(), contentType, _logger);
AddResponseHeaders(result, responseHeaders);
return result;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ private object GetCachedResult(IRequest requestContext, IDictionary<string, stri
AddAgeHeader(responseHeaders, lastDateModified);
AddExpiresHeader(responseHeaders, cacheKeyString, cacheDuration);

var result = new HttpResult(new byte[] { }, contentType ?? "text/html", HttpStatusCode.NotModified);
var result = new HttpResult(Array.Empty<byte>(), contentType ?? "text/html", HttpStatusCode.NotModified);

AddResponseHeaders(result, responseHeaders);

Expand Down Expand Up @@ -610,7 +610,7 @@ public async Task<object> GetStaticResult(IRequest requestContext, StaticResultO
{
stream.Dispose();

return GetHttpResult(requestContext, new byte[] { }, contentType, true, responseHeaders);
return GetHttpResult(requestContext, Array.Empty<byte>(), contentType, true, responseHeaders);
}

var hasHeaders = new StreamWriter(stream, contentType, _logger)
Expand Down
15 changes: 0 additions & 15 deletions Emby.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public async Task<QueryParamCollection> GetFormData()
await LoadWwwForm(form).ConfigureAwait(false);
}

form.Protect();

#if NET_4_0
if (validateRequestNewMode && !checked_form) {
// Setting this before calling the validator prevents
Expand Down Expand Up @@ -282,19 +280,6 @@ void AddRawKeyValue(WebROCollection form, StringBuilder key, StringBuilder value

class WebROCollection : QueryParamCollection
{
bool got_id;
int id;

public void Protect()
{
//IsReadOnly = true;
}

public void Unprotect()
{
//IsReadOnly = false;
}

public override string ToString()
{
StringBuilder result = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ public WebSocketState State
{
get
{
WebSocketState commonState;

if (!Enum.TryParse(WebSocket.ReadyState.ToString(), true, out commonState))
{
_logger.Warn("Unrecognized WebSocketState: {0}", WebSocket.ReadyState.ToString());
}

return commonState;
return WebSocket.ReadyState;
}
}

Expand Down
Loading

0 comments on commit 1142dd1

Please sign in to comment.