diff options
| author | Luke <luke.pulverenti@gmail.com> | 2013-12-25 20:07:29 -0800 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2013-12-25 20:07:29 -0800 |
| commit | 7c8424bf611b90cf27ce8d8d94b26f0da612d114 (patch) | |
| tree | a5ae5be0c1de2572698d02683bfe7968ed6c4b15 | |
| parent | cf094f9a6d19e484006781ac21262eb3fafdcbf2 (diff) | |
| parent | 320495a5653ba931f5f1545954364e0e06d35b00 (diff) | |
Merge pull request #652 from abeloin/master
Linux fixes
10 files changed, 123 insertions, 35 deletions
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 071f5bdde..2bebe7ee5 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -209,8 +209,9 @@ <PostBuildEvent Condition=" '$(ConfigurationName)' != 'Release Mono' ">if '$(ConfigurationName)' == 'Release' ( xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\net45\" /y /d /r /i )</PostBuildEvent> + <PostBuildEvent Condition=" '$(ConfigurationName)' == 'Release Mono' ">cp -fu "$(MSBuildProjectDirectory)\..\packages\PropertyChanged.Fody.1.41.0.0\PropertyChanged.Fody.dll" "$(MSBuildProjectDirectory)\..\Tools\Fody\"</PostBuildEvent> </PropertyGroup> - <Import Project="$(SolutionDir)\.nuget\nuget.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " /> + <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " /> <Import Project="Fody.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. diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index fbe78e938..7ce0cad73 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -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)) { diff --git a/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs b/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs index a0b7ff515..0f35a766a 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs @@ -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> diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 09a39c3eb..2023596b3 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -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. diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs index 9836de735..0b3d5f784 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs @@ -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; diff --git a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs index 8be35071a..e46dab23e 100644 --- a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs +++ b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs @@ -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) diff --git a/MediaBrowser.Server.Mono/FFMpeg/FFMpegDownloadInfo.cs b/MediaBrowser.Server.Mono/FFMpeg/FFMpegDownloadInfo.cs index 970e5a3e0..7cb7278dc 100644 --- a/MediaBrowser.Server.Mono/FFMpeg/FFMpegDownloadInfo.cs +++ b/MediaBrowser.Server.Mono/FFMpeg/FFMpegDownloadInfo.cs @@ -1,20 +1,57 @@ - +using System; + namespace MediaBrowser.ServerApplication.FFMpeg { public static class FFMpegDownloadInfo { - public static string Version = "ffmpeg20130904"; + public static string Version = ffmpegOsType("Version"); - public static string[] FfMpegUrls = new[] - { - "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2013-10-11.tar.gz", + public static string[] FfMpegUrls = ffmpegOsType("FfMpegUrls").Split(','); - "https://www.dropbox.com/s/b9v17h105cps7p0/ffmpeg.static.32bit.2013-10-11.tar.gz?dl=1" - }; + public static string FFMpegFilename = ffmpegOsType("FFMpegFilename"); + public static string FFProbeFilename = ffmpegOsType("FFProbeFilename"); - public static string FFMpegFilename = "ffmpeg"; - public static string FFProbeFilename = "ffprobe"; + public static string ArchiveType = ffmpegOsType("ArchiveType"); - public static string ArchiveType = "gz"; + private static string ffmpegOsType(string arg) + { + OperatingSystem os = Environment.OSVersion; + PlatformID pid = os.Platform; + switch (pid) + { + case PlatformID.Win32NT: + switch (arg) + { + case "Version": + return "ffmpeg20131221"; + case "FfMpegUrls": + return "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20131221-git-70d6ce7-win32-static.7z,https://www.dropbox.com/s/d38uj7857trbw1g/ffmpeg-20131209-git-a12f679-win32-static.7z?dl=1"; + case "FFMpegFilename": + return "ffmpeg.exe"; + case "FFProbeFilename": + return "ffprobe.exe"; + case "ArchiveType": + return "7z"; + } + break; + case PlatformID.Unix: + case PlatformID.MacOSX: + switch (arg) + { + case "Version": + return "ffmpeg20131221"; + case "FfMpegUrls": + return "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2013-12-21.tar.gz,https://www.dropbox.com/s/b9v17h105cps7p0/ffmpeg.static.32bit.2013-10-11.tar.gz?dl=1"; + case "FFMpegFilename": + return "ffmpeg"; + case "FFProbeFilename": + return "ffprobe"; + case "ArchiveType": + return "gz"; + } + break; + } + return ""; + } } } diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index 39321876c..d37330821 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -50,6 +50,7 @@ <Reference Include="ServiceStack.Interfaces"> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> </Reference> + <Reference Include="Mono.Posix" Condition=" '$(ConfigurationName)' == 'Release Mono' "/> </ItemGroup> <ItemGroup> <Compile Include="..\SharedVersion.cs"> @@ -127,8 +128,11 @@ </ItemGroup> <ItemGroup> <None Include="app.config" /> - <None Include="sqlite3.dll"> + </ItemGroup> + <ItemGroup> + <Content Include="..\ThirdParty\SQLite3\x86\3.8.2\sqlite3.dll"> + <Link>sqlite3.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> + </Content> </ItemGroup> </Project>
\ No newline at end of file diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index cf0b4c6d7..59fc11c07 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -102,7 +102,9 @@ namespace MediaBrowser.Server.Mono Console.WriteLine ("appHost.Init"); - var task = _appHost.Init(); + var initProgress = new Progress<double>(); + + var task = _appHost.Init(initProgress); Task.WaitAll (task); Console.WriteLine ("Running startup tasks"); diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs index d257ff362..1e99c4eb0 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs @@ -12,6 +12,9 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +#if __MonoCS__ +using Mono.Unix.Native; +#endif namespace MediaBrowser.ServerApplication.FFMpeg { @@ -147,6 +150,13 @@ namespace MediaBrowser.ServerApplication.FFMpeg })) { File.Copy(file, Path.Combine(targetFolder, Path.GetFileName(file)), true); + #if __MonoCS__ + //Linux: File permission to 666, and user's execute bit + if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) + { + Syscall.chmod(Path.Combine(targetFolder, Path.GetFileName(file)), FilePermissions.DEFFILEMODE | FilePermissions.S_IXUSR); + } + #endif } } finally |
