Moved temporary files into a folder of their own below the data directory (#1245)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-29 18:45:34 +01:00
1 parent ddfc632b63
commit 12d3e1ec6c
52 files changed
+1219 -396

No files matched your search

@@ -376,10 +376,7 @@ public sealed class BflMaterialService(BeyondFactsLabStore store, RustService ru
return FileExtractionResult.Failed(FileExtractionErrorCode.INVALID_REQUEST, "No transcription provider may hear the recordings of the BeyondFacts Lab.");
}
if (SettingsManager.DataDirectory is not { } dataDirectory)
return FileExtractionResult.Failed(FileExtractionErrorCode.INTERNAL, "The data directory of AI Studio is not known yet.");
var location = new BflTranscriptLocation(dataDirectory);
var location = new BflTranscriptLocation();
try
{
var transcript = await PersistentMediaTranscript.ReadOrCreateAsync(location, path, provider, mediaTranscriptionService.TranscribeAsync, logger, CancellationToken.None);
@@ -7,18 +7,12 @@ namespace AIStudio.Assistants.BeyondFactsLab;
/// </summary>
/// <remarks>
/// The lab keeps only the filtered text of a transcript, as the text of the material. The transcript itself lies in
/// a folder of its own below media-staging of the data directory, which the lab deletes once it has read the
/// transcript; whatever a crash leaves there, TranscriptStagingCleanupService removes with the next start. Backups
/// leave that folder out.
/// a folder of its own in the temporary folder of AI Studio, which the lab deletes once it has read the transcript;
/// whatever a crash leaves there is gone with the next start of AI Studio, see TemporaryFiles. Backups leave that
/// folder out.
/// </remarks>
/// <param name="dataDirectory">The data directory of AI Studio.</param>
internal sealed class BflTranscriptLocation(string dataDirectory) : IMediaTranscriptLocation
internal sealed class BflTranscriptLocation : IMediaTranscriptLocation
{
/// <summary>
/// The folder of the data directory for transcripts on their way, shared with the chat; see TranscriptStagingCleanupService.
/// </summary>
private const string STAGING_DIRECTORY_NAME = "media-staging";
/// <summary>
/// The name of the transcript in its folder.
/// </summary>
@@ -27,7 +21,7 @@ internal sealed class BflTranscriptLocation(string dataDirectory) : IMediaTransc
/// <summary>
/// Gets the folder of this transcript, which no other one shares.
/// </summary>
public string FolderPath { get; } = Path.Combine(dataDirectory, STAGING_DIRECTORY_NAME, $"bfl-{Guid.NewGuid():N}");
public string FolderPath { get; } = TemporaryFiles.CreateDirectory();
/// <inheritdoc />
public Task<MediaTranscriptSlot> ResolveAsync(string mediaPath, CancellationToken token)
@@ -20086,6 +20086,12 @@ UI_TEXT_CONTENT["AISTUDIO::PROVIDER::BASEPROVIDER::T1133173666"] = "The provider
-- The provider '{0}' refused the request. Your account might not be allowed to use the selected model, or the provider might not serve your region.
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::BASEPROVIDER::T1133173666::INFORMAL"] = "The provider '{0}' refused the request. Your account might not be allowed to use the selected model, or the provider might not serve your region."
-- AI Studio could not send the media file to the provider '{0}', because the connection to it failed. Please try again.
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::BASEPROVIDER::T171993942"] = "AI Studio could not send the media file to the provider '{0}', because the connection to it failed. Please try again."
-- AI Studio could not send the media file to the provider '{0}', because the connection to it failed. Please try again.
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::BASEPROVIDER::T171993942::INFORMAL"] = "AI Studio could not send the media file to the provider '{0}', because the connection to it failed. Please try again."
-- Tried to stream the LLM provider '{0}' answer. Was not able to read the stream. The message is: '{1}'
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::BASEPROVIDER::T1856278860"] = "Tried to stream the LLM provider '{0}' answer. Was not able to read the stream. The message is: '{1}'"
@@ -143,6 +143,8 @@ public partial class VisualBriefingAssistant : MSGComponentBase
/// </summary>
protected override async Task OnInitializedAsync()
{
// Taken before the first await: Blazor may dispose the page meanwhile, see "Loops of a component" in app/AGENTS.md:
var sourceMonitorToken = this.sourceMonitorCancellation.Token;
await base.OnInitializedAsync();
if (!this.SettingsManager.IsAssistantVisible(
ComponentKind.VISUAL_BRIEFING_ASSISTANT,
@@ -158,7 +160,10 @@ public partial class VisualBriefingAssistant : MSGComponentBase
this.BuildProgressService.Changed += this.BuildProgressChanged;
await this.ReloadListAsync();
await this.ConsumePendingMediaOutcomesAsync();
this.MonitorSourceStatusAsync(this.sourceMonitorCancellation.Token).Observe($"{nameof(VisualBriefingAssistant)}: monitoring the source status");
if (sourceMonitorToken.IsCancellationRequested)
return;
this.MonitorSourceStatusAsync(sourceMonitorToken).Observe($"{nameof(VisualBriefingAssistant)}: monitoring the source status");
if (AssistantLaunchService.TakeTextPayload(ComponentKind.VISUAL_BRIEFING_ASSISTANT) is { } textLaunchPayload && !string.IsNullOrWhiteSpace(textLaunchPayload.Text))
{
// A text sent here starts a briefing of its own, which holds what the text demands. The briefing
@@ -55,8 +55,11 @@ public partial class VisualBriefingBuildProgress : MSGComponentBase
protected override async Task OnInitializedAsync()
{
// Taken before the first await: Blazor may dispose the component meanwhile, see "Loops of a component" in app/AGENTS.md:
var durationMonitorToken = this.durationMonitorCancellation.Token;
await base.OnInitializedAsync();
this.MonitorBuildDurationAsync(this.durationMonitorCancellation.Token).Observe($"{nameof(VisualBriefingBuildProgress)}: monitoring the build duration");
if (!durationMonitorToken.IsCancellationRequested)
this.MonitorBuildDurationAsync(durationMonitorToken).Observe($"{nameof(VisualBriefingBuildProgress)}: monitoring the build duration");
}
protected override void OnParametersSet()
@@ -21,9 +21,8 @@ internal sealed class VisualBriefingSourcePreparationService(VisualBriefingStore
/// <returns>The prepared sources.</returns>
public async Task<VisualBriefingPreparedSources> PrepareAsync(VisualBriefingManifest manifest, Guid operationId, Guid buildId, CancellationToken token)
{
var temporaryDirectory = Path.Combine(Path.GetTempPath(), $"mwai-visual-briefing-{Guid.NewGuid():N}");
Directory.CreateDirectory(temporaryDirectory);
var temporaryDirectory = TemporaryFiles.CreateDirectory();
try
{
List<FileAttachment> attachments = [];