mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-22 06:31:29 +00:00
Fix file lock not getting disposed when postamble throws an exception
This commit is contained in:
@@ -23,9 +23,16 @@ internal partial class MessageExporter : IAsyncDisposable
|
||||
{
|
||||
if (_writer is not null)
|
||||
{
|
||||
await _writer.WritePostambleAsync(cancellationToken);
|
||||
await _writer.DisposeAsync();
|
||||
_writer = null;
|
||||
try
|
||||
{
|
||||
await _writer.WritePostambleAsync(cancellationToken);
|
||||
}
|
||||
// Writer must be disposed, even if writing postamble fails
|
||||
finally
|
||||
{
|
||||
await _writer.DisposeAsync();
|
||||
_writer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,7 @@ internal class HtmlMessageWriter : MessageWriter
|
||||
}
|
||||
|
||||
// Use <!--wmm:ignore--> to preserve blocks of code inside the templates
|
||||
private string Minify(string html) => _minifier
|
||||
.Minify(html, false)
|
||||
.MinifiedContent;
|
||||
private string Minify(string html) => _minifier.Minify(html, false).MinifiedContent;
|
||||
|
||||
public override async ValueTask WritePreambleAsync(
|
||||
CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user