aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-21 13:50:14 -0500
committerGitHub <noreply@github.com>2016-11-21 13:50:14 -0500
commite439bbba42c082b8e50ff35d6dba68857b62c9aa (patch)
tree432bc48932b75dd48d92db96b2b550a21f757546
parentbc113bf095b03cb1ecef06c8675a888792b33d7d (diff)
parent62f84acd2640de815992436ceb392b199af656de (diff)
Merge pull request #2300 from MediaBrowser/dev
Dev
-rw-r--r--Emby.Server.Implementations/Data/SqliteFileOrganizationRepository.cs161
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicGenre.cs9
-rw-r--r--MediaBrowser.Controller/Entities/GameGenre.cs9
-rw-r--r--MediaBrowser.Controller/Entities/Genre.cs9
-rw-r--r--MediaBrowser.Controller/Entities/Studio.cs9
-rw-r--r--MediaBrowser.Controller/Entities/Year.cs9
-rw-r--r--MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj11
-rw-r--r--MediaBrowser.Server.Mono/Program.cs25
-rw-r--r--MediaBrowser.Server.Mono/packages.config1
10 files changed, 173 insertions, 74 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteFileOrganizationRepository.cs b/Emby.Server.Implementations/Data/SqliteFileOrganizationRepository.cs
index efc0ee2ed..2d1aabf5f 100644
--- a/Emby.Server.Implementations/Data/SqliteFileOrganizationRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteFileOrganizationRepository.cs
@@ -59,28 +59,34 @@ namespace Emby.Server.Implementations.Data
using (var connection = CreateConnection())
{
- connection.RunInTransaction(db =>
+ using (WriteLock.Write())
{
- var paramList = new List<object>();
- var commandText = "replace into FileOrganizerResults (ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
-
- paramList.Add(result.Id.ToGuidParamValue());
- paramList.Add(result.OriginalPath);
- paramList.Add(result.TargetPath);
- paramList.Add(result.FileSize);
- paramList.Add(result.Date.ToDateTimeParamValue());
- paramList.Add(result.Status.ToString());
- paramList.Add(result.Type.ToString());
- paramList.Add(result.StatusMessage);
- paramList.Add(result.ExtractedName);
- paramList.Add(result.ExtractedSeasonNumber);
- paramList.Add(result.ExtractedEpisodeNumber);
- paramList.Add(result.ExtractedEndingEpisodeNumber);
- paramList.Add(string.Join("|", result.DuplicatePaths.ToArray()));
-
-
- db.Execute(commandText, paramList.ToArray());
- });
+ connection.RunInTransaction(db =>
+ {
+ var commandText = "replace into FileOrganizerResults (ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (@ResultId, @OriginalPath, @TargetPath, @FileLength, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber, @DuplicatePaths)";
+
+ using (var statement = db.PrepareStatement(commandText))
+ {
+ statement.TryBind("@ResultId", result.Id.ToGuidParamValue());
+ statement.TryBind("@OriginalPath", result.OriginalPath);
+
+ statement.TryBind("@TargetPath", result.TargetPath);
+ statement.TryBind("@FileLength", result.FileSize);
+ statement.TryBind("@OrganizationDate", result.Date.ToDateTimeParamValue());
+ statement.TryBind("@Status", result.Status.ToString());
+ statement.TryBind("@OrganizationType", result.Type.ToString());
+ statement.TryBind("@StatusMessage", result.StatusMessage);
+ statement.TryBind("@ExtractedName", result.ExtractedName);
+ statement.TryBind("@ExtractedYear", result.ExtractedYear);
+ statement.TryBind("@ExtractedSeasonNumber", result.ExtractedSeasonNumber);
+ statement.TryBind("@ExtractedEpisodeNumber", result.ExtractedEpisodeNumber);
+ statement.TryBind("@ExtractedEndingEpisodeNumber", result.ExtractedEndingEpisodeNumber);
+ statement.TryBind("@DuplicatePaths", string.Join("|", result.DuplicatePaths.ToArray()));
+
+ statement.MoveNext();
+ }
+ });
+ }
}
}
@@ -93,15 +99,17 @@ namespace Emby.Server.Implementations.Data
using (var connection = CreateConnection())
{
- connection.RunInTransaction(db =>
+ using (WriteLock.Write())
{
- var paramList = new List<object>();
- var commandText = "delete from FileOrganizerResults where ResultId = ?";
-
- paramList.Add(id.ToGuidParamValue());
-
- db.Execute(commandText, paramList.ToArray());
- });
+ connection.RunInTransaction(db =>
+ {
+ using (var statement = db.PrepareStatement("delete from FileOrganizerResults where ResultId = @ResultId"))
+ {
+ statement.TryBind("@ResultId", id.ToGuidParamValue());
+ statement.MoveNext();
+ }
+ });
+ }
}
}
@@ -109,12 +117,15 @@ namespace Emby.Server.Implementations.Data
{
using (var connection = CreateConnection())
{
- connection.RunInTransaction(db =>
+ using (WriteLock.Write())
{
- var commandText = "delete from FileOrganizerResults";
+ connection.RunInTransaction(db =>
+ {
+ var commandText = "delete from FileOrganizerResults";
- db.Execute(commandText);
- });
+ db.Execute(commandText);
+ });
+ }
}
}
@@ -127,34 +138,45 @@ namespace Emby.Server.Implementations.Data
using (var connection = CreateConnection(true))
{
- var commandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults";
-
- if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
- {
- commandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM FileOrganizerResults ORDER BY OrganizationDate desc LIMIT {0})",
- query.StartIndex.Value.ToString(_usCulture));
- }
-
- commandText += " ORDER BY OrganizationDate desc";
-
- if (query.Limit.HasValue)
+ using (WriteLock.Read())
{
- commandText += " LIMIT " + query.Limit.Value.ToString(_usCulture);
+ var commandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults";
+
+ if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
+ {
+ commandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM FileOrganizerResults ORDER BY OrganizationDate desc LIMIT {0})",
+ query.StartIndex.Value.ToString(_usCulture));
+ }
+
+ commandText += " ORDER BY OrganizationDate desc";
+
+ if (query.Limit.HasValue)
+ {
+ commandText += " LIMIT " + query.Limit.Value.ToString(_usCulture);
+ }
+
+ var list = new List<FileOrganizationResult>();
+
+ using (var statement = connection.PrepareStatement(commandText))
+ {
+ foreach (var row in statement.ExecuteQuery())
+ {
+ list.Add(GetResult(row));
+ }
+ }
+
+ int count;
+ using (var statement = connection.PrepareStatement("select count (ResultId) from FileOrganizerResults"))
+ {
+ count = statement.ExecuteQuery().SelectScalarInt().First();
+ }
+
+ return new QueryResult<FileOrganizationResult>()
+ {
+ Items = list.ToArray(),
+ TotalRecordCount = count
+ };
}
-
- var list = new List<FileOrganizationResult>();
- var count = connection.Query("select count (ResultId) from FileOrganizerResults").SelectScalarInt().First();
-
- foreach (var row in connection.Query(commandText))
- {
- list.Add(GetResult(row));
- }
-
- return new QueryResult<FileOrganizationResult>()
- {
- Items = list.ToArray(),
- TotalRecordCount = count
- };
}
}
@@ -167,16 +189,21 @@ namespace Emby.Server.Implementations.Data
using (var connection = CreateConnection(true))
{
- var paramList = new List<object>();
-
- paramList.Add(id.ToGuidParamValue());
-
- foreach (var row in connection.Query("select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=?", paramList.ToArray()))
+ using (WriteLock.Read())
{
- return GetResult(row);
+ using (var statement = connection.PrepareStatement("select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=@ResultId"))
+ {
+ statement.TryBind("@ResultId", id.ToGuidParamValue());
+ statement.MoveNext();
+
+ foreach (var row in statement.ExecuteQuery())
+ {
+ return GetResult(row);
+ }
+ }
+
+ return null;
}
-
- return null;
}
}
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index 9f7cce13b..feeb212f1 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -159,8 +159,8 @@ namespace Emby.Server.Implementations.Data
{
using (var statement = db.PrepareStatement("replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
{
- statement.TryBind("@UserId", userId.ToGuidParamValue());
- statement.TryBind("@Key", key);
+ statement.TryBind("@userId", userId.ToGuidParamValue());
+ statement.TryBind("@key", key);
if (userData.Rating.HasValue)
{
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs
index c930f2563..d75b31f6a 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs
@@ -31,6 +31,15 @@ namespace MediaBrowser.Controller.Entities.Audio
get { return true; }
}
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
+
/// <summary>
/// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself
diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs
index d62d3c8fd..22a8675c5 100644
--- a/MediaBrowser.Controller/Entities/GameGenre.cs
+++ b/MediaBrowser.Controller/Entities/GameGenre.cs
@@ -37,6 +37,15 @@ namespace MediaBrowser.Controller.Entities
}
}
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
+
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>
diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs
index 731391bc4..da4ee352f 100644
--- a/MediaBrowser.Controller/Entities/Genre.cs
+++ b/MediaBrowser.Controller/Entities/Genre.cs
@@ -40,6 +40,15 @@ namespace MediaBrowser.Controller.Entities
}
}
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
+
public override bool IsSaveLocalMetadataEnabled()
{
return true;
diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs
index 508eb1514..ec623eeda 100644
--- a/MediaBrowser.Controller/Entities/Studio.cs
+++ b/MediaBrowser.Controller/Entities/Studio.cs
@@ -39,6 +39,15 @@ namespace MediaBrowser.Controller.Entities
}
}
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
+
public override bool CanDelete()
{
return false;
diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs
index ab904cbd8..75fb69435 100644
--- a/MediaBrowser.Controller/Entities/Year.cs
+++ b/MediaBrowser.Controller/Entities/Year.cs
@@ -33,6 +33,15 @@ namespace MediaBrowser.Controller.Entities
}
}
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
+
public override bool CanDelete()
{
return false;
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index 485bbf3a9..13d67ace5 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -88,15 +88,16 @@
<HintPath>..\packages\SQLitePCLRaw.core.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.core.dll</HintPath>
<Private>True</Private>
</Reference>
+ <Reference Include="SQLitePCLRaw.provider.sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62684c7b4f184e3f, processorArchitecture=MSIL">
+ <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
<Reference Include="System" />
<Reference Include="MediaBrowser.IsoMounting.Linux">
<HintPath>..\ThirdParty\MediaBrowser.IsoMounting.Linux\MediaBrowser.IsoMounting.Linux.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
- <Reference Include="System.Data.SQLite">
- <HintPath>..\ThirdParty\SQLitePCLRaw.provider.sqlite3.net45\System.Data.SQLite.dll</HintPath>
- </Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
@@ -222,6 +223,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
+ <None Include="SQLitePCLRaw.provider.sqlite3.dll.config">
+ <SubType>Designer</SubType>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
<None Include="System.Data.SQLite.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs
index 39a537e1e..88951c0f6 100644
--- a/MediaBrowser.Server.Mono/Program.cs
+++ b/MediaBrowser.Server.Mono/Program.cs
@@ -35,9 +35,11 @@ namespace MediaBrowser.Server.Mono
public static void Main(string[] args)
{
- SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
-
var applicationPath = Assembly.GetEntryAssembly().Location;
+ var appFolderPath = Path.GetDirectoryName(applicationPath);
+
+ TryCopySqliteConfigFile(appFolderPath);
+ SetSqliteProvider();
var options = new StartupOptions(Environment.GetCommandLineArgs());
@@ -68,6 +70,25 @@ namespace MediaBrowser.Server.Mono
}
}
+ private static void TryCopySqliteConfigFile(string appFolderPath)
+ {
+ try
+ {
+ File.Copy(Path.Combine(appFolderPath, "System.Data.SQLite.dll.config"),
+ Path.Combine(appFolderPath, "SQLitePCLRaw.provider.sqlite3.dll.config"),
+ true);
+ }
+ catch
+ {
+
+ }
+ }
+
+ private static void SetSqliteProvider()
+ {
+ SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
+ }
+
private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath)
{
if (string.IsNullOrEmpty(programDataPath))
diff --git a/MediaBrowser.Server.Mono/packages.config b/MediaBrowser.Server.Mono/packages.config
index 6e3fe428c..e82ef0ed0 100644
--- a/MediaBrowser.Server.Mono/packages.config
+++ b/MediaBrowser.Server.Mono/packages.config
@@ -6,4 +6,5 @@
<package id="SharpCompress" version="0.14.0" targetFramework="net46" />
<package id="SimpleInjector" version="3.2.4" targetFramework="net46" />
<package id="SQLitePCLRaw.core" version="1.1.1-pre20161109081005" targetFramework="net46" />
+ <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.1-pre20161109081005" targetFramework="net46" />
</packages> \ No newline at end of file