1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-05-11 20:34:03 +02:00

Delete broken backup archive in case archival fails after the file is created

This commit is contained in:
chylex 2023-02-05 11:00:22 +01:00
parent b5129e2f70
commit c7354dce0e
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548

View File

@ -109,10 +109,21 @@ sealed class BackupArchiver {
return true;
} catch (Exception e) {
logger.Error(e, "Could not create archive.");
DeleteBrokenArchiveFile(backupFilePath);
return false;
}
}
private void DeleteBrokenArchiveFile(string filePath) {
if (File.Exists(filePath)) {
try {
File.Delete(filePath);
} catch (Exception e) {
logger.Error(e, "Could not delete broken archive: {File}", filePath);
}
}
}
private async Task CopyDirectory(DirectoryInfo sourceFolder, string destinationFolderPath, ImmutableList<string> relativePath) {
cancellationToken.ThrowIfCancellationRequested();