MCPcopy Index your code
hub / github.com/kopia/kopia / LoadEntries

Function LoadEntries

internal/acl/acl_manager.go:72–110  ·  view source on GitHub ↗

LoadEntries returns the set of all ACLs in the repository, using old list as a cache.

(ctx context.Context, rep repo.Repository, old []*Entry)

Source from the content-addressed store, hash-verified

70
71// LoadEntries returns the set of all ACLs in the repository, using old list as a cache.
72func LoadEntries(ctx context.Context, rep repo.Repository, old []*Entry) ([]*Entry, error) {
73 if rep == nil {
74 return nil, nil
75 }
76
77 entries, err := rep.FindManifests(ctx, map[string]string{
78 manifest.TypeLabelKey: aclManifestType,
79 })
80 if err != nil {
81 return nil, errors.Wrap(err, "error listing ACL manifests")
82 }
83
84 om := map[manifest.ID]*Entry{}
85 for _, v := range old {
86 om[v.ManifestID] = v
87 }
88
89 result := []*Entry{}
90
91 for _, m := range entries {
92 if o := om[m.ID]; o != nil {
93 result = append(result, o)
94 continue
95 }
96
97 var p Entry
98
99 _, err := rep.GetManifest(ctx, m.ID, &p)
100 if err != nil {
101 return nil, errors.Wrapf(err, "error loading ACL manifest %v", m.ID)
102 }
103
104 p.ManifestID = m.ID
105
106 result = append(result, &p)
107 }
108
109 return result, nil
110}
111
112// AddACL validates and adds the specified ACL entry to the repository.
113func AddACL(ctx context.Context, w repo.RepositoryWriter, e *Entry, overwrite bool) error {

Callers 6

runMethod · 0.92
runMethod · 0.92
runMethod · 0.92
AuthorizeMethod · 0.92
TestLoadEntriesFunction · 0.92
AddACLFunction · 0.85

Calls 2

FindManifestsMethod · 0.65
GetManifestMethod · 0.65

Tested by 1

TestLoadEntriesFunction · 0.74