Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed Jan 27, 2019
1 parent b04bb64 commit 339defb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions LibgenDesktop.Setup/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 = "1.2.3";
public const string TITLE_VERSION = "1.2.3";
public const string CURRENT_VERSION = "1.2.4";
public const string TITLE_VERSION = "1.2.4";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + TITLE_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
Expand Down
6 changes: 3 additions & 3 deletions LibgenDesktop/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace LibgenDesktop.Common
internal static class Constants
{
public const string DATABASE_METADATA_APP_NAME = "LibgenDesktop";
public const string CURRENT_VERSION = "1.2.3";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.2.3";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2019, 1, 2);
public const string CURRENT_VERSION = "1.2.4";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.2.4";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2019, 1, 27);
public const string CURRENT_DATABASE_VERSION = "1.2.1";

public const string APP_SETTINGS_FILE_NAME = "libgen.config";
Expand Down
10 changes: 5 additions & 5 deletions LibgenDesktop/Models/Database/LocalDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public DatabaseMetadata GetMetadata()
while (dataReader.Read())
{
string key = dataReader.GetString(0);
string value = dataReader.GetString(1);
string value = ParseNullableDbString(dataReader.GetValue(1));
if (DatabaseMetadata.FieldDefinitions.TryGetValue(key.ToLower(), out DatabaseMetadata.FieldDefinition field))
{
field.Setter(result, value);
Expand Down Expand Up @@ -1511,7 +1511,7 @@ private LibraryFile ReadFile(SQLiteDataReader dataReader)
LibraryFile file = new LibraryFile();
file.Id = dataReader.GetInt32(0);
file.FilePath = dataReader.GetString(1);
file.ArchiveEntry = ParseStringScalarResult(dataReader.GetValue(2));
file.ArchiveEntry = ParseNullableDbString(dataReader.GetValue(2));
file.ObjectType = (LibgenObjectType)dataReader.GetInt32(3);
file.ObjectId = dataReader.GetInt32(4);
return file;
Expand Down Expand Up @@ -1546,7 +1546,7 @@ private int ExecuteIntScalarCommand(string commandText)

private string ExecuteStringScalarCommand(string commandText)
{
return ParseStringScalarResult(ExecuteScalarCommand(commandText));
return ParseNullableDbString(ExecuteScalarCommand(commandText));
}

private object ExecuteScalarCommand(string commandText)
Expand All @@ -1568,9 +1568,9 @@ private int ParseIntScalarResult(object objectResult)
return objectResult != DBNull.Value ? (int?)(long)objectResult : null;
}

private string ParseStringScalarResult(object objectResult)
private string ParseNullableDbString(object input)
{
return objectResult != DBNull.Value ? objectResult.ToString() : null;
return input != DBNull.Value ? input.ToString() : null;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
6 changes: 4 additions & 2 deletions LibgenDesktop/Models/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,9 @@ public bool OpenDatabase(string databaseFilePath)
UpdateFictionBookCount();
UpdateSciMagArticleCount();
}
catch
catch (Exception exception)
{
Logger.Exception(exception);
LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
return false;
}
Expand Down Expand Up @@ -748,8 +749,9 @@ public bool CreateDatabase(string databaseFilePath)
SciMagArticleCount = 0;
return true;
}
catch
catch (Exception exception)
{
Logger.Exception(exception);
LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
return false;
}
Expand Down

0 comments on commit 339defb

Please sign in to comment.