MCPcopy
hub / github.com/filebrowser/filebrowser / getSharesForAdminPath

Function getSharesForAdminPath

http/share.go:111–135  ·  view source on GitHub ↗
(d *data, path string)

Source from the content-addressed store, hash-verified

109})
110
111func getSharesForAdminPath(d *data, path string) ([]*share.Link, error) {
112 links, err := d.store.Share.All()
113 if err != nil {
114 return nil, err
115 }
116
117 adminPath := filepath.Clean(d.user.FullPath(path))
118 owners := make(map[uint]*users.User)
119 filtered := make([]*share.Link, 0, len(links))
120 for _, link := range links {
121 owner, ok := owners[link.UserID]
122 if !ok {
123 owner, err = d.store.Users.Get(d.server.Root, d.server.FollowExternalSymlinks, link.UserID)
124 if err != nil && !errors.Is(err, fberrors.ErrNotExist) {
125 return nil, err
126 }
127 owners[link.UserID] = owner // owner is nil on ErrNotExist
128 }
129 if owner != nil && filepath.Clean(owner.FullPath(link.Path)) == adminPath {
130 filtered = append(filtered, link)
131 }
132 }
133
134 return filtered, nil
135}
136
137var shareDeleteHandler = withPermShare(func(_ http.ResponseWriter, r *http.Request, d *data) (int, error) {
138 hash := strings.TrimSuffix(r.URL.Path, "/")

Callers 1

share.goFile · 0.85

Calls 4

FullPathMethod · 0.80
AllMethod · 0.65
GetMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected