mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-28 11:56:28 +00:00
fix: retention policy display may show default values for some fields
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/garethgeorge/backrest/internal/config/validationutil"
|
||||
"github.com/gitploy-io/cronexpr"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func ValidateConfig(c *v1.Config) error {
|
||||
@@ -107,6 +108,10 @@ func validatePlan(plan *v1.Plan, repos map[string]*v1.Repo) error {
|
||||
|
||||
if plan.Retention != nil && plan.Retention.Policy == nil {
|
||||
err = multierror.Append(err, errors.New("retention policy must be nil or must specify a policy"))
|
||||
} else if policyTimeBucketed, ok := plan.Retention.Policy.(*v1.RetentionPolicy_PolicyTimeBucketed); ok {
|
||||
if proto.Equal(policyTimeBucketed.PolicyTimeBucketed, &v1.RetentionPolicy_TimeBucketedCounts{}) {
|
||||
err = multierror.Append(err, errors.New("time bucketed policy must specify a non-empty bucket"))
|
||||
}
|
||||
}
|
||||
|
||||
slices.Sort(plan.Paths)
|
||||
|
||||
@@ -147,7 +147,7 @@ export class BackupInfoCollector {
|
||||
constructor(
|
||||
private filter: (op: Operation) => boolean = (op) =>
|
||||
!shouldHideOperation(op),
|
||||
) {}
|
||||
) { }
|
||||
|
||||
private createBackup(operations: Operation[]): BackupInfo {
|
||||
// deduplicate and sort operations.
|
||||
@@ -414,7 +414,7 @@ export const detailsForOperation = (
|
||||
color = "grey";
|
||||
break;
|
||||
case OperationStatus.STATUS_INPROGRESS:
|
||||
state = "runnning";
|
||||
state = "running";
|
||||
duration = new Date().getTime() - Number(op.unixTimeStartMs);
|
||||
color = "blue";
|
||||
break;
|
||||
|
||||
@@ -67,7 +67,7 @@ export const AddPlanModal = ({ template }: { template: Plan | null }) => {
|
||||
|
||||
alertsApi.success(
|
||||
"Plan deleted from config, but not from restic repo. Snapshots will remain in storage and operations will be tracked until manually deleted. Reusing a deleted plan ID is not recommended if backups have already been performed.",
|
||||
30,
|
||||
30
|
||||
);
|
||||
} catch (e: any) {
|
||||
alertsApi.error("Operation failed: " + e.message, 15);
|
||||
@@ -492,18 +492,6 @@ const RetentionPolicyView = () => {
|
||||
const form = Form.useFormInstance();
|
||||
const retention = Form.useWatch("retention", { form, preserve: true }) as any;
|
||||
|
||||
if (!retention) {
|
||||
form.setFieldValue("retention", {
|
||||
policyTimeBucketed: {
|
||||
yearly: 0,
|
||||
monthly: 3,
|
||||
weekly: 4,
|
||||
daily: 7,
|
||||
hourly: 24,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const determineMode = () => {
|
||||
if (!retention) {
|
||||
return "policyTimeBucketed";
|
||||
|
||||
Reference in New Issue
Block a user