|
|
@ -46,20 +46,22 @@ public class LiteDbContext : ILiteDbContext |
|
|
|
{ |
|
|
|
{ |
|
|
|
db = new LiteDatabaseAsync(":temp:"); |
|
|
|
db = new LiteDatabaseAsync(":temp:"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
// Attempt to create connection, might be in use |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var dbPath = Path.Combine(settingsManager.LibraryDir, "StabilityMatrix.db"); |
|
|
|
// Attempt to create connection, might be in use |
|
|
|
db = new LiteDatabaseAsync(new ConnectionString() |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
Filename = dbPath, |
|
|
|
var dbPath = Path.Combine(settingsManager.LibraryDir, "StabilityMatrix.db"); |
|
|
|
Connection = ConnectionType.Shared, |
|
|
|
db = new LiteDatabaseAsync(new ConnectionString() |
|
|
|
}); |
|
|
|
{ |
|
|
|
} |
|
|
|
Filename = dbPath, |
|
|
|
catch (IOException e) |
|
|
|
Connection = ConnectionType.Shared, |
|
|
|
{ |
|
|
|
}); |
|
|
|
logger.LogWarning("Database in use or not accessible ({Message}), using temporary database", e.Message); |
|
|
|
} |
|
|
|
|
|
|
|
catch (IOException e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
logger.LogWarning("Database in use or not accessible ({Message}), using temporary database", e.Message); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Fallback to temporary database |
|
|
|
// Fallback to temporary database |
|
|
@ -136,12 +138,15 @@ public class LiteDbContext : ILiteDbContext |
|
|
|
return changed; |
|
|
|
return changed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<GithubCacheEntry?> GetGithubCacheEntry(string cacheKey) |
|
|
|
public async Task<GithubCacheEntry?> GetGithubCacheEntry(string? cacheKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(cacheKey)) return null; |
|
|
|
|
|
|
|
|
|
|
|
if (await GithubCache.FindByIdAsync(cacheKey).ConfigureAwait(false) is { } result) |
|
|
|
if (await GithubCache.FindByIdAsync(cacheKey).ConfigureAwait(false) is { } result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|