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:
parent
b5129e2f70
commit
c7354dce0e
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user