Skip to content

Commit

Permalink
7z reader fix
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed Feb 21, 2018
1 parent 90b7ec8 commit b790387
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LibgenDesktop.Setup/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
internal static class Constants
{
public const string CURRENT_VERSION = "0.13.1";
public const string CURRENT_VERSION = "0.13.2";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + CURRENT_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
internal static class Constants
{
public const string CURRENT_VERSION = "0.13.1";
public const string CURRENT_GITHUB_RELEASE_NAME = "v0.13.1 alpha";
public const string CURRENT_VERSION = "0.13.2";
public const string CURRENT_GITHUB_RELEASE_NAME = "v0.13.2 alpha";
public const string CURRENT_DATABASE_VERSION = "0.7";

public const string APP_SETTINGS_FILE_NAME = "libgen.config";
Expand Down
1 change: 1 addition & 0 deletions LibgenDesktop/LibgenDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<Compile Include="Models\SqlDump\ColumnType.cs" />
<Compile Include="Models\Import\Importer.cs" />
<Compile Include="Models\Import\NonFictionImporter.cs" />
<Compile Include="Models\SqlDump\PositioningStreamReader.cs" />
<Compile Include="Models\SqlDump\SqlDumpReader.cs" />
<Compile Include="Models\SqlDump\TableDefinition.cs" />
<Compile Include="Models\SqlDump\TableDefinitions.cs" />
Expand Down
58 changes: 58 additions & 0 deletions LibgenDesktop/Models/SqlDump/PositioningStreamReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.IO;

namespace LibgenDesktop.Models.SqlDump
{
internal class PositioningStream : Stream
{
private readonly Stream baseStream;
private long position;

public PositioningStream(Stream baseStream)
{
this.baseStream = baseStream;
position = 0;
}

public override bool CanRead => true;
public override bool CanSeek => false;
public override bool CanWrite => false;
public override long Length => throw new NotImplementedException();

public override long Position
{
get => position;
set => throw new NotImplementedException();
}

public override void Flush()
{
throw new NotImplementedException();
}

public override int Read(byte[] buffer, int offset, int count)
{
int result = baseStream.Read(buffer, offset, count);
if (result > 0)
{
position += result;
}
return result;
}

public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}

public override void SetLength(long value)
{
throw new NotImplementedException();
}

public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
}
}
2 changes: 1 addition & 1 deletion LibgenDesktop/Models/SqlDump/SqlDumpReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public SqlDumpReader(string filePath)
sevenZipArchive = SevenZipArchive.Open(filePath);
SevenZipArchiveEntry firstSevenZipArchiveEntry = sevenZipArchive.Entries.First();
FileSize = firstSevenZipArchiveEntry.Size;
streamReader = new StreamReader(firstSevenZipArchiveEntry.OpenEntryStream());
streamReader = new StreamReader(new PositioningStream(firstSevenZipArchiveEntry.OpenEntryStream()));
break;
default:
FileSize = new FileInfo(filePath).Length;
Expand Down

0 comments on commit b790387

Please sign in to comment.