mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-19 13:15:44 +02:00
Compare commits
2 Commits
c55f936d95
...
119d478a92
Author | SHA1 | Date | |
---|---|---|---|
119d478a92 | |||
9908d8b9cb |
@ -11,9 +11,7 @@ public sealed partial class NewDatabaseSettingsDialog : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnClosing(object? sender, WindowClosingEventArgs e) {
|
private void OnClosing(object? sender, WindowClosingEventArgs e) {
|
||||||
if (!e.IsProgrammatic) {
|
e.Cancel = true;
|
||||||
e.Cancel = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClickOk(object? sender, RoutedEventArgs e) {
|
private void ClickOk(object? sender, RoutedEventArgs e) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<Button Command="{Binding MergeWithDatabase}">Merge with Database(s)...</Button>
|
<Button Command="{Binding MergeWithDatabase}">Merge with Database(s)...</Button>
|
||||||
<Button Command="{Binding ImportLegacyArchive}">Import Legacy Archive(s)...</Button>
|
<Button Command="{Binding ImportLegacyArchive}">Import Legacy Archive(s)...</Button>
|
||||||
</WrapPanel>
|
</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">
|
<StackPanel Orientation="Vertical" Spacing="10">
|
||||||
<TextBlock TextWrapping="Wrap">Recreate the database to free up space after deleting data.</TextBlock>
|
<TextBlock TextWrapping="Wrap">Recreate the database to free up space after deleting data.</TextBlock>
|
||||||
<Button Command="{Binding VacuumDatabase}">Vacuum Database</Button>
|
<Button Command="{Binding VacuumDatabase}">Vacuum Database</Button>
|
||||||
|
@ -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) {
|
public async Task AddDownload(Data.Download item, Stream? stream) {
|
||||||
await using (var conn = await pool.Take()) {
|
await using (var conn = await pool.Take()) {
|
||||||
|
string schema = conn.HasAttachedDatabase(Schema) ? Schema : "main";
|
||||||
|
|
||||||
await conn.BeginTransactionAsync();
|
await conn.BeginTransactionAsync();
|
||||||
|
|
||||||
await using var metadataCmd = conn.Upsert("download_metadata", [
|
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);
|
upsertBlobCmd.AddAndSet(":blob_length", SqliteType.Integer, item.Size);
|
||||||
long rowid = await upsertBlobCmd.ExecuteLongScalarAsync();
|
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);
|
await stream.CopyToAsync(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +218,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
|
|||||||
rowid = reader.GetInt64(0);
|
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);
|
await dataProcessor(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +253,7 @@ sealed class SqliteDownloadRepository(SqliteConnectionPool pool) : BaseSqliteRep
|
|||||||
rowid = reader.GetInt64(2);
|
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);
|
await dataProcessor(new Data.Download(normalizedUrl, downloadUrl, DownloadStatus.Success, type, (ulong) blob.Length), blob, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user