MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / props

Function props

server/webdav/prop.go:176–222  ·  view source on GitHub ↗

TODO(nigeltao) merge props and allprop? Props returns the status of the properties named pnames for resource name. Each Propstat has a unique status and each property name will only be part of one Propstat element.

(ctx context.Context, ls LockSystem, fi model.Obj, pnames []xml.Name)

Source from the content-addressed store, hash-verified

174// Each Propstat has a unique status and each property name will only be part
175// of one Propstat element.
176func props(ctx context.Context, ls LockSystem, fi model.Obj, pnames []xml.Name) ([]Propstat, error) {
177 //f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0)
178 //if err != nil {
179 // return nil, err
180 //}
181 //defer f.Close()
182 //fi, err := f.Stat()
183 //if err != nil {
184 // return nil, err
185 //}
186 isDir := fi.IsDir()
187
188 var deadProps map[xml.Name]Property
189 // ??? what is this for?
190 //if dph, ok := f.(DeadPropsHolder); ok {
191 // deadProps, err = dph.DeadProps()
192 // if err != nil {
193 // return nil, err
194 // }
195 //}
196
197 pstatOK := Propstat{Status: http.StatusOK}
198 pstatNotFound := Propstat{Status: http.StatusNotFound}
199 for _, pn := range pnames {
200 // If this file has dead properties, check if they contain pn.
201 if dp, ok := deadProps[pn]; ok {
202 pstatOK.Props = append(pstatOK.Props, dp)
203 continue
204 }
205 // Otherwise, it must either be a live property or we don't know it.
206 if prop := liveProps[pn]; prop.findFn != nil && (prop.dir || !isDir) {
207 innerXML, err := prop.findFn(ctx, ls, fi.GetName(), fi)
208 if err != nil {
209 return nil, err
210 }
211 pstatOK.Props = append(pstatOK.Props, Property{
212 XMLName: pn,
213 InnerXML: []byte(innerXML),
214 })
215 } else {
216 pstatNotFound.Props = append(pstatNotFound.Props, Property{
217 XMLName: pn,
218 })
219 }
220 }
221 return makePropstats(pstatOK, pstatNotFound), nil
222}
223
224// Propnames returns the property names defined for resource name.
225func propnames(ctx context.Context, ls LockSystem, fi model.Obj) ([]xml.Name, error) {

Callers 2

allpropFunction · 0.70
handlePropfindMethod · 0.70

Calls 3

makePropstatsFunction · 0.85
IsDirMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected