fix: remove database when check connect to sqlite
This commit is contained in:
parent
6f9bfd3880
commit
0ced152fc9
@ -20,6 +20,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
@ -93,6 +94,10 @@ public class SetupController(
|
||||
connection.Open();
|
||||
connection.Close();
|
||||
|
||||
if (connection is SqliteConnection)
|
||||
SqliteConnection.ClearAllPools();
|
||||
}
|
||||
|
||||
var general = GeneralConfig;
|
||||
general.DbSettings = new DbSettings
|
||||
{
|
||||
@ -152,12 +157,21 @@ public class SetupController(
|
||||
else
|
||||
Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite);
|
||||
}
|
||||
else
|
||||
else if (Directory.GetDirectories(path).Length != 0 ||
|
||||
!Directory.GetFiles(path).Select(x => string.Equals(Path.GetFileName(x), "database.db3")).All(x => x))
|
||||
throw new ControllerArgumentException("Such a folder exists. Enter a different name");
|
||||
|
||||
string connectionString = $"Data Source={PathBuilder.Combine(path, "database.db3")}";
|
||||
var filePath = Path.Combine(path, "database.db3");
|
||||
var connectionString = $"Data Source={filePath}";
|
||||
|
||||
return SetDatabase<SqliteConnection, SqliteException>(connectionString, DbSettings.DatabaseEnum.Sqlite);
|
||||
//System.IO.File.Create(filePath);
|
||||
|
||||
var result = SetDatabase<SqliteConnection, SqliteException>(connectionString, DbSettings.DatabaseEnum.Sqlite);
|
||||
|
||||
foreach (var file in Directory.GetFiles(path))
|
||||
System.IO.File.Delete(file);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost("SetRedis")]
|
||||
|
Loading…
Reference in New Issue
Block a user