Merge pull request #652 from abeloin/master

Linux fixes
This commit is contained in:
Luke
2013-12-25 20:07:29 -08:00
10 changed files with 123 additions and 35 deletions

View File

@@ -228,8 +228,17 @@ namespace MediaBrowser.Server.Implementations.Drawing
// Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here
using (var thumbnail = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppPArgb))
{
#if __MonoCS__
// Mono throw an exeception if assign 0 to SetResolution
if (originalImage.HorizontalResolution != 0 && originalImage.VerticalResolution != 0)
{
// Preserve the original resolution
thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution);
}
#else
// Preserve the original resolution
thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution);
#endif
using (var thumbnailGraph = Graphics.FromImage(thumbnail))
{

View File

@@ -28,7 +28,18 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// </summary>
public async void Run()
{
#if __MonoCS__
try
{
await _userManager.RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
}
catch
{
System.Console.WriteLine("RefreshUsersMetadata task error: No users? First time running?");
}
#else
await _userManager.RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
#endif
}
/// <summary>

View File

@@ -48,9 +48,6 @@
<Reference Include="Alchemy">
<HintPath>..\packages\Alchemy.2.2.1\lib\net40\Alchemy.dll</HintPath>
</Reference>
<Reference Include="Mono.Data.Sqlite">
<HintPath>..\ThirdParty\Mono.Data.Sqlite\Mono.Data.Sqlite.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Api.Swagger">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath>
</Reference>
@@ -67,9 +64,14 @@
<Reference Include="BDInfo">
<HintPath>..\packages\MediaBrowser.BdInfo.1.0.0.5\lib\net20\BDInfo.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite">
<Reference Include="System.Data.SQLite" Condition=" '$(ConfigurationName)' != 'Release Mono' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x86.1.0.89.0\lib\net45\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite" Condition=" '$(ConfigurationName)' == 'Release Mono' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\x86\1.0.90.0\net40\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="ServiceStack">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
</Reference>
@@ -85,6 +87,7 @@
<Reference Include="ServiceStack.Text">
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="Mono.Posix" Condition=" '$(ConfigurationName)' == 'Release Mono' " />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
@@ -345,6 +348,16 @@
</Content>
<EmbeddedResource Include="Localization\Ratings\be.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="..\ThirdParty\System.Data.SQLite.ManagedOnly\x86\1.0.90.0\net40\System.Data.SQLite.dll" Condition=" '$(ConfigurationName)' == 'Release Mono'">
<Link>System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ThirdParty\System.Data.SQLite.ManagedOnly\x86\1.0.90.0\net40\System.Data.SQLite.Linq.dll" Condition=" '$(ConfigurationName)' == 'Release Mono'">
<Link>System.Data.SQLite.Linq.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,11 +1,7 @@
using MediaBrowser.Model.Logging;
using System;
using System.Data;
#if __MonoCS__
using Mono.Data.Sqlite;
#else
using System.Data.SQLite;
#endif
using System.IO;
using System.Threading.Tasks;
@@ -140,18 +136,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
logger.Info("Opening {0}", dbPath);
#if __MonoCS__
var connectionstr = new SqliteConnectionStringBuilder
{
PageSize = 4096,
CacheSize = 4096,
SyncMode = SynchronizationModes.Normal,
DataSource = dbPath,
JournalMode = SQLiteJournalModeEnum.Off
};
var connection = new SqliteConnection(connectionstr.ConnectionString);
#else
var connectionstr = new SQLiteConnectionStringBuilder
{
PageSize = 4096,
@@ -162,7 +146,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
};
var connection = new SQLiteConnection(connectionstr.ConnectionString);
#endif
await connection.OpenAsync().ConfigureAwait(false);
return connection;

View File

@@ -4,6 +4,9 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net;
#if __MonoCS__
using Mono.Unix.Native;
#endif
namespace MediaBrowser.Server.Implementations.WebSocket
{
@@ -66,6 +69,20 @@ namespace MediaBrowser.Server.Implementations.WebSocket
TimeOut = TimeSpan.FromHours(24)
};
#if __MonoCS__
//Linux: port below 1024 require root or cap_net_bind_service
if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
{
if (Syscall.getuid() == 0)
{
WebSocketServer.FlashAccessPolicyEnabled = true;
}
else
{
WebSocketServer.FlashAccessPolicyEnabled = false;
}
}
#endif
WebSocketServer.Start();
}
catch (Exception ex)