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)
| 174 | // Each Propstat has a unique status and each property name will only be part |
| 175 | // of one Propstat element. |
| 176 | func 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. |
| 225 | func propnames(ctx context.Context, ls LockSystem, fi model.Obj) ([]xml.Name, error) { |
no test coverage detected