fix: Cleans up archiving and fixes wrong relative path used (#825)

This commit is contained in:
Kamron Batman 2021-10-09 14:36:46 -07:00 committed by GitHub
parent 507eba34a8
commit fe0abc4a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View file

@ -14,7 +14,8 @@ namespace Server.Compression
// bsdtar has a bug and hangs, so we are doing it in two steps.
if (Core.IsWindows)
{
var tempTarArchive = Path.Combine(Core.BaseDirectory, "temp/temp-file.tar");
var tempDir = PathUtility.EnsureRandomPath(Path.GetTempPath());
var tempTarArchive = Path.Combine(tempDir, "temp-file.tar");
try
{
@ -54,11 +55,12 @@ namespace Server.Compression
// bsdtar has a bug and hangs, so we are doing it in two steps.
if (Core.IsWindows)
{
var tempTarArchive = Path.Combine(Core.BaseDirectory, "temp/temp-file.tar");
var tempDir = PathUtility.EnsureRandomPath(Path.GetTempPath());
var tempTarArchive = Path.Combine(tempDir, "temp-file.tar");
try
{
if (!TarArchive.CreateFromPaths(paths, relativeTo, tempTarArchive))
if (!TarArchive.CreateFromPaths(paths, tempTarArchive, relativeTo))
{
return false;
}
@ -83,7 +85,7 @@ namespace Server.Compression
}
finally
{
File.Delete(tempTarArchive);
Directory.Delete(tempDir, true);
}
}