37cf19c405
Relocate both the framework multipart buffer (via ASPNETCORE_TEMP) and the controller staging file to a configurable data-disk directory, so large WAV/FLAC/MP3 uploads no longer fail on the host's small tmpfs.
60 lines
2.6 KiB
C#
60 lines
2.6 KiB
C#
using DeepDrftAPI;
|
|
|
|
namespace DeepDrftTests;
|
|
|
|
/// <summary>
|
|
/// Guards the upload-staging directory resolution (<see cref="Startup.ResolveStagingPath"/>). The
|
|
/// load-bearing invariant: large audio bodies must stage on the data disk, never the system temp
|
|
/// mount — on the Linux host /tmp is a small RAM-backed tmpfs that cannot hold a multi-hundred-MB WAV.
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class UploadStagingPathTests
|
|
{
|
|
[Test]
|
|
public void ResolveStagingPath_DefaultsToStagingUnderVault_WhenUnconfigured()
|
|
{
|
|
var vaultPath = Path.Combine(Path.GetTempPath(), "DeepDrftTests", Guid.NewGuid().ToString());
|
|
|
|
foreach (var configured in new[] { null, "", " " })
|
|
{
|
|
var resolved = Startup.ResolveStagingPath(configured, vaultPath);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(resolved, Is.EqualTo(Path.GetFullPath(Path.Combine(vaultPath, "staging"))),
|
|
"An unset/blank StagingPath must default to a 'staging' subdirectory under the vault path");
|
|
Assert.That(Path.IsPathFullyQualified(resolved), Is.True,
|
|
"The resolved staging path must be absolute");
|
|
});
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void ResolveStagingPath_HonoursExplicitOverride()
|
|
{
|
|
var vaultPath = Path.Combine("data", "vaults");
|
|
var configured = Path.Combine(Path.GetTempPath(), "DeepDrftTests", "custom-staging", Guid.NewGuid().ToString());
|
|
|
|
var resolved = Startup.ResolveStagingPath(configured, vaultPath);
|
|
|
|
Assert.That(resolved, Is.EqualTo(Path.GetFullPath(configured)),
|
|
"An explicit Upload:StagingPath must win over the vault-path default");
|
|
}
|
|
|
|
[Test]
|
|
public void ResolveStagingPath_NeverResolvesIntoSystemTempDirectory_ForDataDiskVault()
|
|
{
|
|
// A production-shaped vault path on the data disk (the real config is a relative "../Database/Vaults").
|
|
// The resolved staging dir must sit under that vault, not under Path.GetTempPath() (= /tmp on Linux).
|
|
var vaultPath = Path.Combine("..", "Database", "Vaults");
|
|
|
|
var resolved = Startup.ResolveStagingPath(configuredPath: null, vaultPath);
|
|
|
|
var systemTemp = Path.GetFullPath(Path.GetTempPath());
|
|
Assert.That(resolved.StartsWith(systemTemp, StringComparison.Ordinal), Is.False,
|
|
"The default staging directory must never live under the system temp mount");
|
|
Assert.That(resolved, Does.EndWith(Path.Combine("Database", "Vaults", "staging")),
|
|
"The default staging directory must hang off the vault path on the data disk");
|
|
}
|
|
}
|