mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-18 10:15:44 +02:00
Compare commits
2 Commits
119d478a92
...
c55f936d95
Author | SHA1 | Date | |
---|---|---|---|
c55f936d95 | |||
58584931dd |
@ -11,7 +11,9 @@ public sealed partial class NewDatabaseSettingsDialog : Window {
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, WindowClosingEventArgs e) {
|
||||
e.Cancel = true;
|
||||
if (!e.IsProgrammatic) {
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClickOk(object? sender, RoutedEventArgs e) {
|
||||
|
@ -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" IsExpanded="True" Margin="0 15 0 0">
|
||||
<Expander Header="Advanced Tools" 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>
|
||||
|
@ -73,10 +73,13 @@ 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", [
|
||||
@ -114,7 +117,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
|
||||
upsertBlobCmd.AddAndSet(":blob_length", SqliteType.Integer, item.Size);
|
||||
long rowid = await upsertBlobCmd.ExecuteLongScalarAsync();
|
||||
|
||||
await using var blob = new SqliteBlob(conn.InnerConnection, databaseName: schema, tableName: "download_blobs", columnName: "blob", rowid);
|
||||
await using var blob = BlobReference(conn, rowid, readOnly: false);
|
||||
await stream.CopyToAsync(blob);
|
||||
}
|
||||
|
||||
@ -218,7 +221,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
|
||||
rowid = reader.GetInt64(0);
|
||||
}
|
||||
|
||||
await using (var blob = new SqliteBlob(conn.InnerConnection, "download_blobs", "blob", rowid, readOnly: true)) {
|
||||
await using (var blob = BlobReference(conn, rowid, readOnly: true)) {
|
||||
await dataProcessor(blob);
|
||||
}
|
||||
|
||||
@ -253,7 +256,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
|
||||
rowid = reader.GetInt64(2);
|
||||
}
|
||||
|
||||
await using (var blob = new SqliteBlob(conn.InnerConnection, "download_blobs", "blob", rowid, readOnly: true)) {
|
||||
await using (var blob = BlobReference(conn, rowid, readOnly: true)) {
|
||||
await dataProcessor(new Data.Download(normalizedUrl, downloadUrl, DownloadStatus.Success, type, (ulong) blob.Length), blob, cancellationToken);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user