Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADDED hard_delete option on resolver configuration #3783

Merged
merged 1 commit into from Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions server/accounts.go
Expand Up @@ -4049,18 +4049,14 @@ func (dr *DirAccResolver) apply(opts ...DirResOption) error {
return nil
}

func NewDirAccResolver(path string, limit int64, syncInterval time.Duration, delete bool, opts ...DirResOption) (*DirAccResolver, error) {
func NewDirAccResolver(path string, limit int64, syncInterval time.Duration, delete deleteType, opts ...DirResOption) (*DirAccResolver, error) {
if limit == 0 {
limit = math.MaxInt64
}
if syncInterval <= 0 {
syncInterval = time.Minute
}
deleteType := NoDelete
if delete {
deleteType = RenameDeleted
}
store, err := NewExpiringDirJWTStore(path, false, true, deleteType, 0, limit, false, 0, nil)
store, err := NewExpiringDirJWTStore(path, false, true, delete, 0, limit, false, 0, nil)
if err != nil {
return nil, err
}
Expand Down
23 changes: 22 additions & 1 deletion server/opts.go
Expand Up @@ -1130,6 +1130,8 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error
}
case map[string]interface{}:
del := false
hdel := false
hdel_set := false
dir := ""
dirType := ""
limit := int64(0)
Expand All @@ -1149,6 +1151,11 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error
_, v := unwrapValue(v, &lt)
del = v.(bool)
}
if v, ok := v["hard_delete"]; ok {
_, v := unwrapValue(v, &lt)
hdel_set = true
hdel = v.(bool)
}
if v, ok := v["limit"]; ok {
_, v := unwrapValue(v, &lt)
limit = v.(int64)
Expand Down Expand Up @@ -1189,12 +1196,26 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error
if del {
*errors = append(*errors, &configErr{tk, "CACHE does not accept allow_delete"})
}
if hdel_set {
*errors = append(*errors, &configErr{tk, "CACHE does not accept hard_delete"})
}
res, err = NewCacheDirAccResolver(dir, limit, ttl, opts...)
case "FULL":
if ttl != 0 {
*errors = append(*errors, &configErr{tk, "FULL does not accept ttl"})
}
res, err = NewDirAccResolver(dir, limit, sync, del, opts...)
if hdel_set && !del {
*errors = append(*errors, &configErr{tk, "hard_delete has no effect without delete"})
}
delete := NoDelete
if del {
if hdel {
delete = HardDelete
} else {
delete = RenameDeleted
}
}
res, err = NewDirAccResolver(dir, limit, sync, delete, opts...)
}
if err != nil {
*errors = append(*errors, &configErr{tk, err.Error()})
Expand Down