mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-05-07 18:15:34 +02:00
- updated nuget packages
- fixed issues where SQLite database files didn't get unlocked after saving - fixed quirks with missing e_sqlite3.dll when running unit tests with Resharper
This commit is contained in:
@@ -61,35 +61,32 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=5.0.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Data.Sqlite.Core.5.0.8\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Data.Sqlite.Core.7.0.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.1.2.1721, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.1.2\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
||||
<Reference Include="SQLitePCLRaw.core, Version=2.1.2.1721, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.core.2.1.2\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
|
||||
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.1.2.1721, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.1.2\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -100,7 +97,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DbChannel.cs" />
|
||||
<Compile Include="IdtvChannelSerializer.cs" />
|
||||
<Compile Include="Serializer.cs" />
|
||||
<Compile Include="SvlSerializer.cs" />
|
||||
<Compile Include="PanasonicPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="XmlSerializer.cs" />
|
||||
@@ -120,13 +117,6 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
|
||||
</Target>
|
||||
<!-- 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">
|
||||
|
||||
@@ -593,56 +593,66 @@ internal class IdtvChannelSerializer : SerializerBase
|
||||
#region SaveTvDb()
|
||||
private void SaveTvDb(IDictionary<ushort, int> newChannelIndexMap)
|
||||
{
|
||||
string connString = "Data Source=" + this.dbFile;
|
||||
using var db = new SqliteConnection(connString);
|
||||
db.Open();
|
||||
|
||||
using var trans = db.BeginTransaction();
|
||||
|
||||
using var upd = db.CreateCommand();
|
||||
upd.CommandText = "update channels set display_number=@progNr, browsable=@browseable, locked=@locked, favorite=@fav, channel_index=@recIdx where _id=@id"; // searchable=@searchable,
|
||||
upd.Parameters.Add("@id", SqliteType.Integer);
|
||||
upd.Parameters.Add("@progNr", SqliteType.Text);
|
||||
upd.Parameters.Add("@browseable", SqliteType.Integer);
|
||||
//upd.Parameters.Add("@searchable", SqliteType.Integer);
|
||||
upd.Parameters.Add("@locked", SqliteType.Integer);
|
||||
upd.Parameters.Add("@fav", SqliteType.Integer);
|
||||
upd.Parameters.Add("@recIdx", SqliteType.Integer);
|
||||
//upd.Parameters.Add("@ipf2", SqliteType.Integer);
|
||||
upd.Prepare();
|
||||
|
||||
using var del = db.CreateCommand();
|
||||
del.CommandText = "delete from channels where _id=@id";
|
||||
del.Parameters.Add("@id", SqliteType.Integer);
|
||||
del.Prepare();
|
||||
|
||||
foreach (var list in this.DataRoot.ChannelLists)
|
||||
try
|
||||
{
|
||||
foreach (var ch in list.Channels)
|
||||
string connString = "Data Source=" + this.dbFile;
|
||||
using var db = new SqliteConnection(connString);
|
||||
db.Open();
|
||||
|
||||
using var trans = db.BeginTransaction();
|
||||
|
||||
using var upd = db.CreateCommand();
|
||||
upd.CommandText = "update channels set display_number=@progNr, browsable=@browseable, locked=@locked, favorite=@fav, channel_index=@recIdx where _id=@id"; // searchable=@searchable,
|
||||
upd.Parameters.Add("@id", SqliteType.Integer);
|
||||
upd.Parameters.Add("@progNr", SqliteType.Text);
|
||||
upd.Parameters.Add("@browseable", SqliteType.Integer);
|
||||
//upd.Parameters.Add("@searchable", SqliteType.Integer);
|
||||
upd.Parameters.Add("@locked", SqliteType.Integer);
|
||||
upd.Parameters.Add("@fav", SqliteType.Integer);
|
||||
upd.Parameters.Add("@recIdx", SqliteType.Integer);
|
||||
//upd.Parameters.Add("@ipf2", SqliteType.Integer);
|
||||
upd.Prepare();
|
||||
|
||||
using var del = db.CreateCommand();
|
||||
del.CommandText = "delete from channels where _id=@id";
|
||||
del.Parameters.Add("@id", SqliteType.Integer);
|
||||
del.Prepare();
|
||||
|
||||
foreach (var list in this.DataRoot.ChannelLists)
|
||||
{
|
||||
if (ch is not DbChannel dbc)
|
||||
continue;
|
||||
if (ch.NewProgramNr < 0 || ch.IsDeleted)
|
||||
foreach (var ch in list.Channels)
|
||||
{
|
||||
del.Parameters["@id"].Value = ch.RecordIndex;
|
||||
del.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
upd.Parameters["@id"].Value = ch.RecordIndex;
|
||||
upd.Parameters["@progNr"].Value = ch.NewProgramNr;
|
||||
upd.Parameters["@browseable"].Value = !ch.Skip;
|
||||
//upd.Parameters["@searchable"].Value = !ch.Hidden;
|
||||
upd.Parameters["@locked"].Value = ch.Lock;
|
||||
upd.Parameters["@fav"].Value = (int)ch.Favorites;
|
||||
upd.Parameters["@recIdx"].Value = newChannelIndexMap[(ushort)dbc.InternalProviderFlag2];
|
||||
//upd.Parameters["@ipf2"].Value = (int)(ushort)dbc.InternalProviderFlag2; // fix broken short/ushort/int sign extension
|
||||
upd.ExecuteNonQuery();
|
||||
if (ch is not DbChannel dbc)
|
||||
continue;
|
||||
if (ch.NewProgramNr < 0 || ch.IsDeleted)
|
||||
{
|
||||
del.Parameters["@id"].Value = ch.RecordIndex;
|
||||
del.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
upd.Parameters["@id"].Value = ch.RecordIndex;
|
||||
upd.Parameters["@progNr"].Value = ch.NewProgramNr;
|
||||
upd.Parameters["@browseable"].Value = !ch.Skip;
|
||||
//upd.Parameters["@searchable"].Value = !ch.Hidden;
|
||||
upd.Parameters["@locked"].Value = ch.Lock;
|
||||
upd.Parameters["@fav"].Value = (int)ch.Favorites;
|
||||
upd.Parameters["@recIdx"].Value = newChannelIndexMap[(ushort)dbc.InternalProviderFlag2];
|
||||
//upd.Parameters["@ipf2"].Value = (int)(ushort)dbc.InternalProviderFlag2; // fix broken short/ushort/int sign extension
|
||||
upd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trans.Commit();
|
||||
trans.Commit();
|
||||
}
|
||||
finally
|
||||
{
|
||||
// force closing the file and releasing the locks
|
||||
SqliteConnection.ClearAllPools();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace ChanSort.Loader.Panasonic
|
||||
}
|
||||
|
||||
// old svl.db / svl.bin formats
|
||||
return new Serializer(inputFile);
|
||||
return new SvlSerializer(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ChanSort.Loader.Panasonic
|
||||
{
|
||||
internal enum ByteOrder { BigEndian, LittleEndian }
|
||||
|
||||
class Serializer : SerializerBase
|
||||
class SvlSerializer : SerializerBase
|
||||
{
|
||||
private readonly ChannelList avbtChannels = new ChannelList(SignalSource.AnalogT, "Analog Antenna");
|
||||
private readonly ChannelList avbcChannels = new ChannelList(SignalSource.AnalogC, "Analog Cable");
|
||||
@@ -38,7 +38,7 @@ namespace ChanSort.Loader.Panasonic
|
||||
}
|
||||
|
||||
#region ctor()
|
||||
public Serializer(string inputFile) : base(inputFile)
|
||||
public SvlSerializer(string inputFile) : base(inputFile)
|
||||
{
|
||||
this.Features.ChannelNameEdit = ChannelNameEditMode.None; // due to the chaos with binary data inside the "sname" string column, writing back a name has undesired side effects
|
||||
this.Features.DeleteMode = DeleteMode.Physically;
|
||||
@@ -171,7 +171,7 @@ namespace ChanSort.Loader.Panasonic
|
||||
throw LoaderException.Fail("File size validation failed");
|
||||
|
||||
using (var stream = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
|
||||
stream.Write(data, offset, data.Length - offset - 4);
|
||||
stream.Write(data, offset, data.Length - offset - 4);
|
||||
|
||||
this.fileHeader = new byte[offset];
|
||||
Array.Copy(data, 0, this.fileHeader, 0, offset);
|
||||
@@ -301,12 +301,15 @@ order by s.ntype,major_channel
|
||||
{
|
||||
this.FileName = tvOutputFile;
|
||||
|
||||
string channelConnString = "Data Source=" + this.workFile;
|
||||
using (var conn = new SqliteConnection(channelConnString))
|
||||
try
|
||||
{
|
||||
string channelConnString = "Data Source=" + this.workFile;
|
||||
using var conn = new SqliteConnection(channelConnString);
|
||||
|
||||
conn.Open();
|
||||
using var trans = conn.BeginTransaction();
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.Transaction = trans;
|
||||
this.WriteChannels(cmd, this.avbtChannels);
|
||||
this.WriteChannels(cmd, this.avbcChannels);
|
||||
this.WriteChannels(cmd, this.dvbtChannels);
|
||||
@@ -319,6 +322,13 @@ order by s.ntype,major_channel
|
||||
cmd.Transaction = null;
|
||||
this.RepairCorruptedDatabaseImage(cmd);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// force closing the file and releasing the locks
|
||||
SqliteConnection.ClearAllPools();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
this.WriteCypheredFile();
|
||||
}
|
||||
@@ -2,6 +2,14 @@
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Data.Sqlite" version="5.0.8" targetFramework="net48" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="5.0.8" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.core" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.0.4" targetFramework="net48" />
|
||||
<package id="Microsoft.Data.Sqlite" version="7.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="7.0.0" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.1.2" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.core" version="2.1.2" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.1.2" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.1.2" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user