fix: always delete staging file on mid-copy abort
Build the staging path before the copy in both UploadTrack and ReplaceAudio so the finally block deletes it on cancellation or IO error, not only on success.
This commit is contained in:
@@ -51,6 +51,12 @@ public class UploadStagingPathTests
|
||||
var resolved = Startup.ResolveStagingPath(configuredPath: null, vaultPath);
|
||||
|
||||
var systemTemp = Path.GetFullPath(Path.GetTempPath());
|
||||
// Note: because vaultPath is relative, Path.GetFullPath resolves it against the CWD, which is
|
||||
// never the system temp directory. The StartsWith guard therefore catches the case where
|
||||
// ResolveStagingPath mistakenly uses Path.GetTempPath() directly, rather than proving the
|
||||
// absolute production path never overlaps with /tmp on any machine. The EndsWith assertion
|
||||
// is the load-bearing check: it verifies the output is rooted under the vault tree, not
|
||||
// under a hard-coded temp location.
|
||||
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")),
|
||||
|
||||
Reference in New Issue
Block a user