fix: Cleans up archiving and fixes wrong relative path used (#825)
This commit is contained in:
parent
507eba34a8
commit
fe0abc4a8f
2 changed files with 10 additions and 7 deletions
|
|
@ -14,7 +14,8 @@ namespace Server.Compression
|
||||||
// bsdtar has a bug and hangs, so we are doing it in two steps.
|
// bsdtar has a bug and hangs, so we are doing it in two steps.
|
||||||
if (Core.IsWindows)
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -54,11 +55,12 @@ namespace Server.Compression
|
||||||
// bsdtar has a bug and hangs, so we are doing it in two steps.
|
// bsdtar has a bug and hangs, so we are doing it in two steps.
|
||||||
if (Core.IsWindows)
|
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
|
try
|
||||||
{
|
{
|
||||||
if (!TarArchive.CreateFromPaths(paths, relativeTo, tempTarArchive))
|
if (!TarArchive.CreateFromPaths(paths, tempTarArchive, relativeTo))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +85,7 @@ namespace Server.Compression
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
File.Delete(tempTarArchive);
|
Directory.Delete(tempDir, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ namespace Server.Saves
|
||||||
foreach (var (rangeStart, sortedBackups) in items)
|
foreach (var (rangeStart, sortedBackups) in items)
|
||||||
{
|
{
|
||||||
var backups = sortedBackups.Values;
|
var backups = sortedBackups.Values;
|
||||||
if (backups.Count == 0)
|
if (backups.Count <= minimum)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -397,7 +397,9 @@ namespace Server.Saves
|
||||||
|
|
||||||
if (TryGetDate(name, out var date))
|
if (TryGetDate(name, out var date))
|
||||||
{
|
{
|
||||||
items.Add(date, item);
|
// Might give wrong results if there is a file that matches:
|
||||||
|
// Example: 2021-09-01, and 2021-09-01-00
|
||||||
|
items[date] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -435,7 +437,6 @@ namespace Server.Saves
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
logger.Warning($"Path was not in the correct date format: {value}");
|
|
||||||
date = DateTime.MinValue;
|
date = DateTime.MinValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue