Skip to content

Commit 9fb69ac

Browse files
committed
Refactor downloads path to asyn;, Improve settings safety; Fixes: GeoDB reads bug, CI products version control
1 parent 3d9664d commit 9fb69ac

17 files changed

Lines changed: 701 additions & 663 deletions

.github/workflows/canary.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ jobs:
154154
/p:GenerateAppxPackageOnBuild=true `
155155
/p:UapAppxPackageBuildMode=SideloadOnly `
156156
/p:AppxPackageDir=AppPackages\ `
157+
/p:AppxPackageVersion=1.0.${{ needs.build.outputs.date }}.${{ github.run_number }}
157158
/p:AppxPackageSigningEnabled=true `
158159
/p:PackageCertificateThumbprint="${{ steps.import_cert.outputs.thumbprint }}" `
159160
/p:PackageCertificateKeyFile= `
@@ -210,10 +211,9 @@ jobs:
210211
prerelease:
211212
needs: build
212213
runs-on: ubuntu-latest
213-
if: >
214-
github.ref == 'refs/heads/develop' &&
215-
(github.event_name == 'push' ||
216-
(github.event_name == 'workflow_dispatch' && inputs.publish_prerelease == true))
214+
if: |
215+
github.ref == 'refs/heads/master' &&
216+
github.event_name == 'push'
217217
218218
steps:
219219
- name: Download build artifact
@@ -234,6 +234,9 @@ jobs:
234234
generateReleaseNotes: true
235235
body: |
236236
Auto-updated canary package.
237+
Date: ${{ needs.build.outputs.date }}
237238
Branch: ${{ github.ref_name }}
238239
Commit: ${{ github.sha }}
239-
Date: ${{ needs.build.outputs.date }}
240+
241+
Trigger: ${{ github.event_name }}
242+
Actor: ${{ github.actor }}

OpenNet/Core/AppSettingsDatabase.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ namespace OpenNet::Core
160160
{
161161
auto str = GetString(category, key);
162162
if (!str) return std::nullopt;
163-
try { return std::stoll(*str); }
164-
catch (...) { return std::nullopt; }
163+
try
164+
{
165+
return std::stoll(*str);
166+
}
167+
catch (...)
168+
{
169+
return std::nullopt;
170+
}
165171
}
166172

167173
void AppSettingsDatabase::SetDouble(std::string const& category,
@@ -179,8 +185,14 @@ namespace OpenNet::Core
179185
{
180186
auto str = GetString(category, key);
181187
if (!str) return std::nullopt;
182-
try { return std::stod(*str); }
183-
catch (...) { return std::nullopt; }
188+
try
189+
{
190+
return std::stod(*str);
191+
}
192+
catch (...)
193+
{
194+
return std::nullopt;
195+
}
184196
}
185197

186198
void AppSettingsDatabase::SetBool(std::string const& category,
@@ -331,15 +343,15 @@ namespace OpenNet::Core
331343
}
332344
}
333345

334-
std::optional<std::wstring_view> AppSettingsDatabase::GetStringW(std::string const& category,
346+
std::optional<std::wstring> AppSettingsDatabase::GetStringW(std::string const& category,
335347
std::string const& key) const
336348
{
337349
std::lock_guard lk(m_mutex);
338350
if (!m_db && !const_cast<AppSettingsDatabase*>(this)->EnsureInitialized()) return std::nullopt;
339351

340352
const char* sql = "SELECT value FROM settings WHERE category = ? AND key = ?;";
341353
sqlite3_stmt* stmt = nullptr;
342-
std::optional<std::wstring_view> result;
354+
std::optional<std::wstring> result;
343355

344356
if (sqlite3_prepare_v2(m_db, sql, -1, &stmt, nullptr) == SQLITE_OK)
345357
{
@@ -349,7 +361,10 @@ namespace OpenNet::Core
349361
if (sqlite3_step(stmt) == SQLITE_ROW)
350362
{
351363
auto text = reinterpret_cast<const wchar_t*>(sqlite3_column_text16(stmt, 0));
352-
if (text) result = std::wstring_view(text);
364+
if (text)
365+
{
366+
result = std::wstring(text);
367+
}
353368
}
354369
sqlite3_finalize(stmt);
355370
}

OpenNet/Core/AppSettingsDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace OpenNet::Core
107107
void SetStringW(std::string const& category, std::string const& key, std::wstring_view const& value);
108108

109109
/// Get a wide-string setting
110-
std::optional<std::wstring_view> GetStringW(std::string const& category, std::string const& key) const;
110+
std::optional<std::wstring> GetStringW(std::string const& category, std::string const& key) const;
111111

112112
// ---------------------------------------------------------------
113113
// Category constants for well-known setting groups

OpenNet/Core/Aria2/Aria2Engine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::filesystem::path OpenNet::Core::Aria2::GetDownloadsFolderPath()
6868
{
6969
static std::filesystem::path cached = ([]() -> std::filesystem::path
7070
{
71-
std::filesystem::path fp(winrt::OpenNet::Core::IO::FileSystem::GetDownloadsPathW());
71+
std::filesystem::path fp(winrt::OpenNet::Core::IO::FileSystem::GetDownloadsPathW().GetResults().c_str());
7272
std::filesystem::create_directories(fp);
7373
return fp;
7474
}());

0 commit comments

Comments
 (0)