mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-12-04 16:24:35 +00:00
Moved temporary files into a folder of their own below the data directory (#1245)
This commit is contained in:
1 parent
ddfc632b63
commit
12d3e1ec6c
52 files changed
+1219
-396
No files matched your search
@@ -21,7 +21,7 @@ public sealed class ChatDraftTests
|
||||
private static readonly FileAttachment MINUTES = new(FileAttachmentType.DOCUMENT, "minutes.pdf", "/documents/minutes.pdf", 2048);
|
||||
private static readonly FileAttachmentImage CHART = new("chart.png", "/documents/chart.png", 4096);
|
||||
private static readonly ManagedTranscriptAttachment TRANSCRIPT = new("meeting-transcript-0001.md", "/data/tempChats/meeting-transcript-0001.md", 512, "meeting.mp4", false);
|
||||
private static readonly ManagedTranscriptAttachment STAGED_TRANSCRIPT = new("4f1c.md", "/data/media-staging/4f1c.md", 256, "kickoff.mp4", true);
|
||||
private static readonly ManagedTranscriptAttachment STAGED_TRANSCRIPT = new("4f1c.md", "/data/tmp/0123456789abcdef0123456789abcdef/4f1c.md", 256, "kickoff.mp4", true);
|
||||
|
||||
[Test]
|
||||
public void MirroringTheComposerKeepsATranscriptItDoesNotShowYet()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools;
|
||||
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace AIStudio.Tests.Chat;
|
||||
|
||||
@@ -9,7 +12,7 @@ namespace AIStudio.Tests.Chat;
|
||||
/// <remarks>
|
||||
/// A transcript carries a full path, which a chat file edited outside the app may point anywhere. AI
|
||||
/// Studio therefore deletes a file only where it keeps transcripts itself: in the transcript folder of a
|
||||
/// chat, or in the staging area.
|
||||
/// chat, or in a folder of its own in the temporary folder of AI Studio.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
[NonParallelizable]
|
||||
@@ -26,12 +29,16 @@ public sealed class ManagedTranscriptAttachmentTests
|
||||
this.testDirectory = Path.Combine(Path.GetTempPath(), $"ai-studio-transcripts-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(this.testDirectory);
|
||||
SettingsManager.DataDirectory = this.testDirectory;
|
||||
|
||||
// The app sets its temporary folder below the same data directory:
|
||||
TemporaryFiles.Initialize(this.testDirectory, NullLogger.Instance);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void RemoveDataDirectory()
|
||||
{
|
||||
SettingsManager.DataDirectory = this.previousDataDirectory;
|
||||
TemporaryFiles.Initialize(TestHost.DATA_DIRECTORY, NullLogger.Instance);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -43,6 +50,33 @@ public sealed class ManagedTranscriptAttachmentTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AStagedTranscriptIsDeletedTogetherWithItsFolder()
|
||||
{
|
||||
var transcript = await ManagedTranscriptAttachment.CreateStagedAsync("/Users/person/Kickoff.mp4", "Guten Tag.");
|
||||
var folder = Path.GetDirectoryName(transcript.FilePath)!;
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(Path.GetDirectoryName(folder), Is.EqualTo(Path.Combine(this.testDirectory, "tmp")), "The transcript waits in the temporary folder of AI Studio.");
|
||||
Assert.That(ManagedTranscriptAttachment.TryDeleteOwnedFile(transcript), Is.True);
|
||||
Assert.That(File.Exists(transcript.FilePath), Is.False);
|
||||
Assert.That(Directory.Exists(folder), Is.False);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AFileDirectlyInTheTemporaryFolderStays()
|
||||
{
|
||||
var file = WriteTranscript(Path.Combine(this.testDirectory, "tmp"));
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(ManagedTranscriptAttachment.TryDeleteOwnedFile(file), Is.False, "A staged transcript has a folder of its own.");
|
||||
Assert.That(File.Exists(file.FilePath), Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheTranscriptOfAWorkspaceChatIsDeleted()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user