Skip to content

Commit

Permalink
Add hard_delete option on resolver configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienVdG committed Jan 13, 2023
1 parent f2b087c commit 8317a4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 1 addition & 5 deletions server/accounts.go
Expand Up @@ -4028,17 +4028,13 @@ 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, deleteType 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)
if err != nil {
return nil, err
Expand Down
20 changes: 19 additions & 1 deletion server/opts.go
Expand Up @@ -1127,6 +1127,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 @@ -1146,6 +1148,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 @@ -1186,12 +1193,23 @@ 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...)
deleteType := NoDelete
if del {
if hdel {
deleteType = HardDelete
} else {
deleteType = RenameDeleted
}
}
res, err = NewDirAccResolver(dir, limit, sync, deleteType, opts...)
}
if err != nil {
*errors = append(*errors, &configErr{tk, err.Error()})
Expand Down

0 comments on commit 8317a4f

Please sign in to comment.