Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
with:
pkgs: boost-json cpr gettext-libintl glib gtest libsecret maddy
triplet: ${{ matrix.variant.triplet }}
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
token: ${{ github.token }}
cache-key: ${{ matrix.variant.triplet }}-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
cache-key: ${{ matrix.variant.triplet }}-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
- name: "Build"
working-directory: ${{github.workspace}}/build
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
with:
pkgs: boost-json cpr gettext-libintl glib gtest maddy
triplet: arm64-osx
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
token: ${{ github.token }}
cache-key: "arm64-osx-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01"
cache-key: "arm64-osx-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c"
- name: "Build"
working-directory: ${{github.workspace}}/build
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
with:
pkgs: boost-json cpr gettext-libintl gtest maddy sqlcipher
triplet: ${{ matrix.variant.triplet }}
revision: b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
revision: 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
token: ${{ github.token }}
cache-key: ${{ matrix.variant.triplet }}-b1b19307e2d2ec1eefbdb7ea069de7d4bcd31f01
cache-key: ${{ matrix.variant.triplet }}-29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
- name: "Build"
working-directory: ${{github.workspace}}/build
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2025.9.3
### Breaking Changes
None
### New APIs
None
### Fixes
#### Database
- Fixed an issue where the sqlite database did not encrypt and decrypt correctly

## 2025.9.2
### Breaking Changes
None
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

#libnick Definition
project ("libnick" LANGUAGES C CXX VERSION 2025.9.2 DESCRIPTION "A cross-platform base for native Nickvision applications.")
project ("libnick" LANGUAGES C CXX VERSION 2025.9.3 DESCRIPTION "A cross-platform base for native Nickvision applications.")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CTest)
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = "libnick"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "2025.9.2"
PROJECT_NUMBER = "2025.9.3"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion include/database/sqlitedatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ namespace Nickvision::Database
};
}

#endif //SQLDATABASE_H
#endif //SQLDATABASE_H
6 changes: 3 additions & 3 deletions manual/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

libnick provides Nickvision apps with a common set of cross-platform APIs for managing system and desktop app functionality such as network management, taskbar icons, translations, app updates, and more.

## 2025.9.2
## 2025.9.3
### Breaking Changes
None
### New APIs
None
### Fixes
#### Helpers
- Fixed a deadlock in `JsonFileBase`
#### Database
- Fixed an issue where the sqlite database did not encrypt and decrypt correctly

## Dependencies
The following are a list of dependencies used by libnick.
Expand Down
30 changes: 25 additions & 5 deletions src/database/sqlitedatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Nickvision::Database
{
throw std::runtime_error("Unable to open sql database.");
}
if(sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) != SQLITE_OK)
if(sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) != SQLITE_OK)
{
m_isEncrypted = true;
m_isUnlocked = false;
Expand Down Expand Up @@ -82,7 +82,7 @@ namespace Nickvision::Database
}
else
{
m_isUnlocked = sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) == SQLITE_OK;
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
}
return m_isUnlocked;
}
Expand All @@ -101,9 +101,29 @@ namespace Nickvision::Database
{
return true;
}
//If empty database, can use sqlite3_key
SqliteStatement statement{ m_database, "SELECT count(*) FROM sqlite_master;" };
int tableCount{ -1 };
if(statement.step() == SqliteStepResult::Row)
{
tableCount = statement.getColumn<int>(0);
}
if(tableCount == 0)
{
if(sqlite3_key(m_database, password.c_str(), static_cast<int>(password.size())) != SQLITE_OK)
{
return false;
}
else
{
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
m_isEncrypted = true;
return true;
}
}
//Create temp encrypted database
std::filesystem::path tempPath{ (m_path.string() + ".encrypt") };
std::string cmd{ "ATTACH DATABASE '" + tempPath.string() + "' AS encrypted KEY '" + password + "'" };
std::string cmd{ "ATTACH DATABASE '" + tempPath.string() + "' AS encrypted KEY '" + password + "'" };
sqlite3_exec(m_database, cmd.c_str(), nullptr, nullptr, nullptr);
sqlite3_exec(m_database, "SELECT sqlcipher_export('encrypted')", nullptr, nullptr, nullptr);
sqlite3_exec(m_database, "DETACH DATABASE encrypted", nullptr, nullptr, nullptr);
Expand All @@ -120,7 +140,7 @@ namespace Nickvision::Database
{
throw std::runtime_error("Unable to open sql database with password.");
}
m_isUnlocked = sqlite3_exec(m_database, "PRAGMA schema_version", nullptr, nullptr, nullptr) == SQLITE_OK;
m_isUnlocked = sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK;
m_isEncrypted = true;
return true;
}
Expand Down Expand Up @@ -202,4 +222,4 @@ namespace Nickvision::Database
}
return *this;
}
}
}