Skip to content

Commit

Permalink
Fix backup check interval.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Aug 23, 2024
1 parent 296d73b commit 1660050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<PackageTags>Squidex HeadlessCMS</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>13.1</Version>
<Version>13.3</Version>
</PropertyGroup>
</Project>
15 changes: 10 additions & 5 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Squidex.CLI.Configuration;
using Squidex.ClientLibrary;

#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable MA0048 // File name must match type name

namespace Squidex.CLI.Commands;
Expand All @@ -26,8 +27,6 @@ public async Task Create(CreateArguments arguments)
{
var session = configuration.StartSession(arguments.App);

var backupStarted = DateTimeOffset.UtcNow.AddMinutes(-5);

await session.Client.Backups.PostBackupAsync();

log.WriteLine("Backup started, waiting for completion...");
Expand All @@ -36,6 +35,9 @@ public async Task Create(CreateArguments arguments)

using (var tcs = new CancellationTokenSource(TimeSpan.FromMinutes(arguments.Timeout)))
{
var backupStarted = DateTimeOffset.UtcNow.AddMinutes(-5);
var backupInterval = TimeSpan.FromSeconds(arguments.Interval);

while (!tcs.Token.IsCancellationRequested)
{
#pragma warning disable CS0612 // Type or member is obsolete
Expand All @@ -48,9 +50,9 @@ public async Task Create(CreateArguments arguments)
foundBackup = backup;
break;
}
}

await Task.Delay(5000, tcs.Token);
await Task.Delay(backupInterval, tcs.Token);
}
}

if (foundBackup == null)
Expand All @@ -65,7 +67,6 @@ public async Task Create(CreateArguments arguments)

await using (var fs = new FileStream(arguments.File, mode))
{
#pragma warning disable CS0612 // Type or member is obsolete
using (var download = await session.Client.Backups.GetBackupContentAsync(foundBackup.Id))

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete

Check warning on line 70 in cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs

View workflow job for this annotation

GitHub Actions / build

'IBackupsClient.GetBackupContentAsync(string, CancellationToken)' is obsolete
#pragma warning restore CS0612 // Type or member is obsolete
{
Expand Down Expand Up @@ -98,6 +99,9 @@ public sealed class CreateArguments : AppArguments
[Option("timeout", Description = "The timeout to wait for the backup in minutes.")]
public int Timeout { get; set; } = 30;

[Option("interval", Description = "The query interval to test if the backup is ready in seconds.")]
public int Interval { get; set; } = 30;

[Option("deleteAfterDownload", Description = "Defines if the created backup shall be deleted from app after the backup task is completed.")]
public bool DeleteAfterDownload { get; set; }

Expand All @@ -109,6 +113,7 @@ public sealed class Validator : AbstractValidator<CreateArguments>
public Validator()
{
RuleFor(x => x.File).NotEmpty();
RuleFor(x => x.Interval).InclusiveBetween(1, 120);
}
}
}
Expand Down

0 comments on commit 1660050

Please sign in to comment.