// readMetaDataForPath reads the metadata from the path
readMetaDataForPath reads the metadata from the path
// readMetaDataForPath reads the metadata from the path
func (f *Fs) readMetaDataForPath(path string, depth string) (info *api.Prop, err error) {
	opts := rest.Opts{
		Method: "PROPFIND",
		Path:   f.filePath(path),
		ExtraHeaders: map[string]string{
			"Depth": depth,
		},
		NoRedirect: true,
	}
	var result api.Multistatus
	var resp *http.Response
	err = f.pacer.Call(func() (bool, error) {
		resp, err = f.srv.CallXML(&opts, nil, &result)
		return shouldRetry(resp, err)
	})
	if apiErr, ok := err.(*api.Error); ok {
		switch apiErr.StatusCode {
		case http.StatusNotFound:
			if f.retryWithZeroDepth && depth != "0" {
				return f.readMetaDataForPath(path, "0")
			}
			return nil, fs.ErrorObjectNotFound
		case http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther:
			return nil, fs.ErrorObjectNotFound
		}
	}
	if err != nil {
		return nil, errors.Wrap(err, "read metadata failed")
	}
	if len(result.Responses) < 1 {
		return nil, fs.ErrorObjectNotFound
	}
	item := result.Responses[0]
	if !item.Props.StatusOK() {
		return nil, fs.ErrorObjectNotFound
	}
	if itemIsDir(&item) {
		return nil, fs.ErrorNotAFile
	}
	return &item.Props, nil
}
func ( f * Fs ) readMetaDataForPath ( path string , depth string ) ( info * api . Prop , err error ) { opts := rest . Opts { Method : " " , Path : f . filePath ( path ) , ExtraHeaders : map [ string ] string { " " : depth , } , NoRedirect : true , } var result api . Multistatus var resp * http . Response err = f . pacer . Call ( func ( ) ( bool , error ) { resp , err = f . srv . CallXML ( & opts , nil , & result ) return shouldRetry ( resp , err ) } ) if apiErr , ok := err . ( * api . Error ) ; ok { switch apiErr . StatusCode { case http . StatusNotFound : if f . retryWithZeroDepth && depth != " " { return f . readMetaDataForPath ( path , " " ) } return nil , fs . ErrorObjectNotFound case http . StatusMovedPermanently , http . StatusFound , http . StatusSeeOther : return nil , fs . ErrorObjectNotFound } } if err != nil { return nil , errors . Wrap ( err , " " ) } if len ( result . Responses ) < 1 { return nil , fs . ErrorObjectNotFound } item := result . Responses [ 0 ] if ! item . Props . StatusOK ( ) { return nil , fs . ErrorObjectNotFound } if itemIsDir ( & item ) { return nil , fs . ErrorNotAFile } return & item . Props , nil }
readMetaDataForPath reads the metadata from the path
readMetaDataForPath reads the metadata from the path
// FIXME how do we read back additional properties? // does not exist // Some sort of redirect - go doesn't deal with these properly (it resets // the method to GET).  However we can assume that if it was redirected the // object was not found.