CountAuthFiles returns the number of auth records available through the provided Store. For filesystem-backed stores, this reflects the number of JSON auth files under the configured directory.
(ctx context.Context, store interface {
List(context.Context) ([]T, error)
})
| 97 | // CountAuthFiles returns the number of auth records available through the provided Store. |
| 98 | // For filesystem-backed stores, this reflects the number of JSON auth files under the configured directory. |
| 99 | func CountAuthFiles[T any](ctx context.Context, store interface { |
| 100 | List(context.Context) ([]T, error) |
| 101 | }) int { |
| 102 | if store == nil { |
| 103 | return 0 |
| 104 | } |
| 105 | if ctx == nil { |
| 106 | ctx = context.Background() |
| 107 | } |
| 108 | entries, err := store.List(ctx) |
| 109 | if err != nil { |
| 110 | log.Debugf("countAuthFiles: failed to list auth records: %v", err) |
| 111 | return 0 |
| 112 | } |
| 113 | return len(entries) |
| 114 | } |
| 115 | |
| 116 | // WritablePath returns the cleaned WRITABLE_PATH environment variable when it is set. |
| 117 | // It accepts both uppercase and lowercase variants for compatibility with existing conventions. |