mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-28 03:46:29 +00:00
feat: accept up to 2 decimals of precision for check % and prune % policies
This commit is contained in:
@@ -1058,7 +1058,7 @@ func (x *CheckPolicy) GetStructureOnly() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CheckPolicy) GetReadDataSubsetPercent() int32 {
|
||||
func (x *CheckPolicy) GetReadDataSubsetPercent() float64 {
|
||||
if x, ok := x.GetMode().(*CheckPolicy_ReadDataSubsetPercent); ok {
|
||||
return x.ReadDataSubsetPercent
|
||||
}
|
||||
@@ -1074,7 +1074,7 @@ type CheckPolicy_StructureOnly struct {
|
||||
}
|
||||
|
||||
type CheckPolicy_ReadDataSubsetPercent struct {
|
||||
ReadDataSubsetPercent int32 `protobuf:"varint,101,opt,name=read_data_subset_percent,json=readDataSubsetPercent,proto3,oneof"` // check a percentage of pack data.
|
||||
ReadDataSubsetPercent float64 `protobuf:"fixed64,101,opt,name=read_data_subset_percent,json=readDataSubsetPercent,proto3,oneof"` // check a percentage of pack data.
|
||||
}
|
||||
|
||||
func (*CheckPolicy_StructureOnly) isCheckPolicy_Mode() {}
|
||||
@@ -2101,7 +2101,7 @@ var file_v1_config_proto_rawDesc = []byte{
|
||||
0x64, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75,
|
||||
0x72, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x39, 0x0a, 0x18, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x64,
|
||||
0x61, 0x74, 0x61, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x65, 0x74, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x18, 0x65, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, 0x61, 0x64,
|
||||
0x6e, 0x74, 0x18, 0x65, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, 0x61, 0x64,
|
||||
0x44, 0x61, 0x74, 0x61, 0x53, 0x75, 0x62, 0x73, 0x65, 0x74, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0xa8, 0x01, 0x0a, 0x08, 0x53, 0x63,
|
||||
0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c,
|
||||
|
||||
@@ -273,7 +273,7 @@ func (r *RepoOrchestrator) Check(ctx context.Context, output io.Writer) error {
|
||||
switch m := r.repoConfig.CheckPolicy.Mode.(type) {
|
||||
case *v1.CheckPolicy_ReadDataSubsetPercent:
|
||||
if m.ReadDataSubsetPercent > 0 {
|
||||
opts = append(opts, restic.WithFlags(fmt.Sprintf("--read-data-subset=%v%%", m.ReadDataSubsetPercent)))
|
||||
opts = append(opts, restic.WithFlags(fmt.Sprintf("--read-data-subset=%.4f%%", m.ReadDataSubsetPercent)))
|
||||
}
|
||||
case *v1.CheckPolicy_StructureOnly:
|
||||
default:
|
||||
|
||||
@@ -114,7 +114,7 @@ message CheckPolicy {
|
||||
|
||||
oneof mode {
|
||||
bool structure_only = 100 [json_name="structureOnly"]; // only check the structure of the repo. No pack data is read.
|
||||
int32 read_data_subset_percent = 101 [json_name="readDataSubsetPercent"]; // check a percentage of pack data.
|
||||
double read_data_subset_percent = 101 [json_name="readDataSubsetPercent"]; // check a percentage of pack data.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -773,7 +773,7 @@ export class CheckPolicy extends Message<CheckPolicy> {
|
||||
/**
|
||||
* check a percentage of pack data.
|
||||
*
|
||||
* @generated from field: int32 read_data_subset_percent = 101;
|
||||
* @generated from field: double read_data_subset_percent = 101;
|
||||
*/
|
||||
value: number;
|
||||
case: "readDataSubsetPercent";
|
||||
@@ -789,7 +789,7 @@ export class CheckPolicy extends Message<CheckPolicy> {
|
||||
static readonly fields: FieldList = proto3.util.newFieldList(() => [
|
||||
{ no: 1, name: "schedule", kind: "message", T: Schedule },
|
||||
{ no: 100, name: "structure_only", kind: "scalar", T: 8 /* ScalarType.BOOL */, oneof: "mode" },
|
||||
{ no: 101, name: "read_data_subset_percent", kind: "scalar", T: 5 /* ScalarType.INT32 */, oneof: "mode" },
|
||||
{ no: 101, name: "read_data_subset_percent", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "mode" },
|
||||
]);
|
||||
|
||||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckPolicy {
|
||||
|
||||
@@ -465,13 +465,13 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
|
||||
>
|
||||
<Form.Item
|
||||
name={["prunePolicy", "maxUnusedPercent"]}
|
||||
initialValue={25}
|
||||
initialValue={10}
|
||||
required={false}
|
||||
>
|
||||
<InputNumber
|
||||
<InputPercent
|
||||
addonBefore={
|
||||
<Tooltip title="The maximum percentage of the repo size that may be unused after a prune operation completes. High values reduce copying at the expense of storage.">
|
||||
<div style={{ width: "12" }}>Max Unused % After Prune</div>
|
||||
<div style={{ width: "12" }}>Max Unused After Prune</div>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
@@ -504,10 +504,10 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
|
||||
initialValue={0}
|
||||
required={false}
|
||||
>
|
||||
<InputNumber
|
||||
<InputPercent
|
||||
addonBefore={
|
||||
<Tooltip title="The percentage of pack data in this repository that will be read and verified. Higher values will use more bandwidth (e.g. 100% will re-read the entire repository on each check).">
|
||||
<div style={{ width: "12" }}>Read Pack Data %</div>
|
||||
<div style={{ width: "12" }}>Read Data %</div>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
@@ -785,3 +785,17 @@ const formatMissingEnvVars = (partialMatches: string[][]): string => {
|
||||
})
|
||||
.join(" or ");
|
||||
};
|
||||
|
||||
const InputPercent = ({ ...props }) => {
|
||||
return (
|
||||
<InputNumber
|
||||
step={1}
|
||||
min={0}
|
||||
max={100}
|
||||
precision={2}
|
||||
controls={false}
|
||||
suffix="%"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user