Refactor: Migliorata gestione percorsi database multi-piattaforma e pulizia file temporanei
- Implementato supporto per percorsi database specifici per OS (Windows, Linux, macOS) - Rimossi file temporanei e di test non necessari dal CredentialManager - Aggiunto supporto per directory di sistema standard per il database delle credenziali - Mantenuto il codice legacy commentato per retrocompatibilità - Aggiunte cartelle di test per future implementazioni
This commit is contained in:
Binary file not shown.
+33
-5
@@ -23,11 +23,39 @@ builder.Services.AddServerSideBlazor();
|
|||||||
builder.Services.AddWindowsService();
|
builder.Services.AddWindowsService();
|
||||||
builder.Services.AddHostedService<BackgroundServices>();
|
builder.Services.AddHostedService<BackgroundServices>();
|
||||||
|
|
||||||
// Add CredentialManager services
|
#region Database Directory Path management
|
||||||
var contentRoot = builder.Environment.ContentRootPath;
|
|
||||||
var dataPath = Path.Combine(contentRoot, "wwwroot", "data");
|
string dbPath = string.Empty;
|
||||||
Directory.CreateDirectory(dataPath); // Assicurati che la directory esista
|
|
||||||
var dbPath = Path.Combine(dataPath, "credentials.db");
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Data_Coupler", "credentials.db");
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
dbPath = "/var/lib/Data_Coupler/credentials.db";
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
dbPath = "/Library/Application Support/Data_Coupler/credentials.db";
|
||||||
|
}
|
||||||
|
|
||||||
|
var dbDirectory = Path.GetDirectoryName(dbPath);
|
||||||
|
if (!Directory.Exists(dbDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dbDirectory!);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region OLD DB PATH
|
||||||
|
// // Add CredentialManager services
|
||||||
|
// var contentRoot = builder.Environment.ContentRootPath;
|
||||||
|
// var dataPath = Path.Combine(contentRoot, "wwwroot", "data");
|
||||||
|
// Directory.CreateDirectory(dataPath); // Assicurati che la directory esista
|
||||||
|
// var dbPath = Path.Combine(dataPath, "credentials.db");
|
||||||
|
#endregion
|
||||||
|
|
||||||
builder.Services.AddDataConnectionCredentialManagement($"Data Source={dbPath}");
|
builder.Services.AddDataConnectionCredentialManagement($"Data Source={dbPath}");
|
||||||
|
|
||||||
// Register IHttpClientFactory
|
// Register IHttpClientFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user