1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2025-04-19 13:15:44 +02:00

Compare commits

..

2 Commits

3 changed files with 7 additions and 12 deletions

View File

@ -11,10 +11,8 @@ public sealed partial class NewDatabaseSettingsDialog : Window {
}
private void OnClosing(object? sender, WindowClosingEventArgs e) {
if (!e.IsProgrammatic) {
e.Cancel = true;
}
}
private void ClickOk(object? sender, RoutedEventArgs e) {
Close();

View File

@ -27,7 +27,7 @@
<Button Command="{Binding MergeWithDatabase}">Merge with Database(s)...</Button>
<Button Command="{Binding ImportLegacyArchive}">Import Legacy Archive(s)...</Button>
</WrapPanel>
<Expander Header="Advanced Tools" Margin="0 15 0 0">
<Expander Header="Advanced Tools" IsExpanded="True" Margin="0 15 0 0">
<StackPanel Orientation="Vertical" Spacing="10">
<TextBlock TextWrapping="Wrap">Recreate the database to free up space after deleting data.</TextBlock>
<Button Command="{Binding VacuumDatabase}">Vacuum Database</Button>

View File

@ -73,13 +73,10 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
}
}
private static SqliteBlob BlobReference(ISqliteConnection conn, long rowid, bool readOnly) {
string schema = conn.HasAttachedDatabase(Schema) ? Schema : "main";
return new SqliteBlob(conn.InnerConnection, databaseName: schema, tableName: "download_blobs", columnName: "blob", rowid, readOnly);
}
public async Task AddDownload(Data.Download item, Stream? stream) {
await using (var conn = await pool.Take()) {
string schema = conn.HasAttachedDatabase(Schema) ? Schema : "main";
await conn.BeginTransactionAsync();
await using var metadataCmd = conn.Upsert("download_metadata", [
@ -117,7 +114,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
upsertBlobCmd.AddAndSet(":blob_length", SqliteType.Integer, item.Size);
long rowid = await upsertBlobCmd.ExecuteLongScalarAsync();
await using var blob = BlobReference(conn, rowid, readOnly: false);
await using var blob = new SqliteBlob(conn.InnerConnection, databaseName: schema, tableName: "download_blobs", columnName: "blob", rowid);
await stream.CopyToAsync(blob);
}
@ -221,7 +218,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
rowid = reader.GetInt64(0);
}
await using (var blob = BlobReference(conn, rowid, readOnly: true)) {
await using (var blob = new SqliteBlob(conn.InnerConnection, "download_blobs", "blob", rowid, readOnly: true)) {
await dataProcessor(blob);
}
@ -256,7 +253,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
rowid = reader.GetInt64(2);
}
await using (var blob = BlobReference(conn, rowid, readOnly: true)) {
await using (var blob = new SqliteBlob(conn.InnerConnection, "download_blobs", "blob", rowid, readOnly: true)) {
await dataProcessor(new Data.Download(normalizedUrl, downloadUrl, DownloadStatus.Success, type, (ulong) blob.Length), blob, cancellationToken);
}