mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
Core: Fix FileClosed events are not triggered after file close.
This commit is contained in:
parent
4b7eed172c
commit
70eb0b4244
|
@ -85,25 +85,20 @@ namespace BililiveRecorder.Core.Recording
|
|||
this.timer.Stop();
|
||||
this.RequestStop();
|
||||
|
||||
try
|
||||
{
|
||||
var openingEventArgs = this.fileOpeningEventArgs;
|
||||
if (openingEventArgs is not null)
|
||||
this.OnRecordFileClosed(new RecordFileClosedEventArgs(this.room)
|
||||
{
|
||||
SessionId = this.SessionId,
|
||||
FullPath = openingEventArgs.FullPath,
|
||||
RelativePath = openingEventArgs.RelativePath,
|
||||
FileOpenTime = openingEventArgs.FileOpenTime,
|
||||
FileCloseTime = DateTimeOffset.Now,
|
||||
Duration = 0,
|
||||
FileSize = file.Length,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.Warning(ex, "Error calling OnRecordFileClosed");
|
||||
}
|
||||
RecordFileClosedEventArgs recordFileClosedEvent;
|
||||
if (this.fileOpeningEventArgs is { } openingEventArgs)
|
||||
recordFileClosedEvent = new RecordFileClosedEventArgs(this.room)
|
||||
{
|
||||
SessionId = this.SessionId,
|
||||
FullPath = openingEventArgs.FullPath,
|
||||
RelativePath = openingEventArgs.RelativePath,
|
||||
FileOpenTime = openingEventArgs.FileOpenTime,
|
||||
FileCloseTime = DateTimeOffset.Now,
|
||||
Duration = 0,
|
||||
FileSize = file.Length,
|
||||
};
|
||||
else
|
||||
recordFileClosedEvent = null;
|
||||
|
||||
try
|
||||
{ file.Dispose(); }
|
||||
|
@ -114,6 +109,16 @@ namespace BililiveRecorder.Core.Recording
|
|||
{ stream.Dispose(); }
|
||||
catch (Exception) { }
|
||||
|
||||
try
|
||||
{
|
||||
if (recordFileClosedEvent is not null)
|
||||
this.OnRecordFileClosed(recordFileClosedEvent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.Warning(ex, "Error calling OnRecordFileClosed");
|
||||
}
|
||||
|
||||
this.OnRecordSessionEnded(EventArgs.Empty);
|
||||
|
||||
this.logger.Information("录制结束");
|
||||
|
|
Loading…
Reference in New Issue
Block a user