mirror of
				https://github.com/chylex/Discord-History-Tracker.git
				synced 2025-10-30 17:17:16 +01: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) { | ||||
| 		if (!e.IsProgrammatic) { | ||||
| 			e.Cancel = true; | ||||
| 		} | ||||
| 		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" 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> | ||||
|   | ||||
| @@ -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); | ||||
| 		} | ||||
| 		 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user