fix(launcher): harden installer transactions
This commit is contained in:
parent
ff6ebb6a6a
commit
3f68895120
21 changed files with 1164 additions and 61 deletions
|
|
@ -9,6 +9,8 @@ namespace AcDream.Bake;
|
|||
/// </summary>
|
||||
public static class BakeOutputTransaction
|
||||
{
|
||||
internal const string StagingMarker = ".acdream-bake.";
|
||||
|
||||
public static TResult WriteValidateAndPublish<TResult>(
|
||||
string destinationPath,
|
||||
Func<string, TResult> writeTemporary,
|
||||
|
|
@ -25,9 +27,7 @@ public static class BakeOutputTransaction
|
|||
throw new InvalidOperationException("destination has no parent directory");
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
string temporaryPath = Path.Combine(
|
||||
directory,
|
||||
$".{Path.GetFileName(fullDestination)}.{Guid.NewGuid():N}.tmp");
|
||||
string temporaryPath = CreateStagingPath(fullDestination, Guid.NewGuid());
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -60,4 +60,21 @@ public static class BakeOutputTransaction
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exact adjacent staging-name contract shared, by documentation and
|
||||
/// conformance tests, with Launcher.Core. Keeping this tiny contract in
|
||||
/// each BCL-facing assembly avoids an otherwise inverted project edge.
|
||||
/// </summary>
|
||||
internal static string CreateStagingPath(string destinationPath, Guid transactionId)
|
||||
{
|
||||
string fullDestination = Path.GetFullPath(destinationPath);
|
||||
string directory = Path.GetDirectoryName(fullDestination)
|
||||
?? throw new InvalidOperationException(
|
||||
"destination has no parent directory");
|
||||
return Path.Combine(
|
||||
directory,
|
||||
$".{Path.GetFileName(fullDestination)}{StagingMarker}"
|
||||
+ $"{transactionId:N}.tmp");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue