Skip to content

Commit

Permalink
Fix dbcreation logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
EngincanV committed May 14, 2024
1 parent 76651c4 commit ff5ac7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/CmsKitDemo/Data/CmsKitConnectionStringResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ private async Task<string> ResolveInternalAsync(string connectionStringName = nu
var demoUserId = _demoNameResolver.GetDemoUserIdOrNull() ?? _configuration["App:DefaultDbName"];

var dbFilePath = $"{dbFolder}{demoUserId}.db";
var connString = $"Data Source={dbFilePath};Cache=Shared";
if (!File.Exists(dbFilePath))
{
File.Copy(_configuration["App:DbFolderName"]?.EnsureEndsWith(Path.DirectorySeparatorChar) + _configuration["App:DefaultDbName"] + ".db", dbFilePath);
}

return connString;
return $"Data Source={dbFilePath};Cache=Shared";
}
}
2 changes: 0 additions & 2 deletions src/CmsKitDemo/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
@using Volo.Abp.Data;
@inject IHtmlLocalizer<CmsKitDemoResource> L
@model CmsKitDemo.Pages.IndexModel
@inject IConnectionStringResolver ConnectionStringResolver

@section styles {
<abp-style src="/Pages/Index.cshtml.css" />
Expand Down Expand Up @@ -34,7 +33,6 @@
</div>
<div class="col-lg-9 col-md-7 col-12 d-flex align-items-center">
<div class="ps-md-3 text-center text-md-start">
<h6 class="mb-0">ABP Framework - @await ConnectionStringResolver.ResolveAsync()</h6>
<h1>CMS Kit Module</h1>
<p class="pd-title mb-4">This module provides CMS (Content Management System) capabilities for your application.</p>
<a href="https://docs.abp.io/en/abp/latest/Modules/Cms-Kit/Index" target="_blank" class="btn btn-primary btn-lg product-btn">Documentation</a>
Expand Down
2 changes: 1 addition & 1 deletion src/CmsKitDemo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"DbFolderName": "CmsKitDemoDb"
},
"ConnectionStrings": {
"Default": "Data Source=/CmsKitDemoDb/CmsKitDemo.db;"
"Default": "Data Source=CmsKitDemoDb/CmsKitDemo.db;"
},
"StringEncryption": {
"DefaultPassPhrase": "cZl2tCN43sVGDX6m"
Expand Down

0 comments on commit ff5ac7c

Please sign in to comment.