Skip to content

Commit

Permalink
More null checking
Browse files Browse the repository at this point in the history
  • Loading branch information
lyze237 committed May 6, 2024
1 parent 150c1d2 commit 7ee399a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Jobs/BackupJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ private async Task Run(CancellationToken stoppingToken)

logger.LogInformation("Uploading {Amount} Folders", allDirectories.Count);
await UploadToProxmox(allDirectories.ToArray());

if (Directory.Exists(postgresDirectory.directory))
Directory.Delete(postgresDirectory.directory, true);
}

private async Task<List<(string, string)>> DoContainerBackups(IList<ContainerListResponse> containers,
Expand Down Expand Up @@ -63,7 +66,7 @@ private async Task Run(CancellationToken stoppingToken)

var mounts = new List<(string, string)>();

foreach (var hostMount in inspect.HostConfig.Mounts)
foreach (var hostMount in inspect.HostConfig.Mounts ?? Array.Empty<Mount>())
{
if (!hostMount.Type.Equals("volume"))
continue;
Expand All @@ -83,7 +86,7 @@ private async Task Run(CancellationToken stoppingToken)
}


private async Task<(string, string)> DoPostgresBackups(IList<ContainerListResponse> containers,
private async Task<(string name, string directory)> DoPostgresBackups(IList<ContainerListResponse> containers,
CancellationToken stoppingToken)
{
var directory = new DirectoryInfo($"/tmp/{DateTime.Now.ToString("O")}");
Expand Down

0 comments on commit 7ee399a

Please sign in to comment.