Skip to content

Commit

Permalink
comment cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 6, 2022
1 parent 859654d commit a40f558
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion internal/http/services/owncloud/ocdav/locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ func (s *svc) handleSpacesLock(w http.ResponseWriter, r *http.Request, spaceID s

span.SetAttributes(attribute.String("component", "ocdav"))

// build storage space reference
ref, err := spacelookup.MakeStorageSpaceReference(spaceID, r.URL.Path)
if err != nil {
return http.StatusBadRequest, fmt.Errorf("invalid space id")
Expand Down
4 changes: 0 additions & 4 deletions internal/http/services/owncloud/ocdav/propfind/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func (p *Handler) HandleSpacesPropfind(w http.ResponseWriter, r *http.Request, s
var space *provider.StorageSpace
if res.Info.Space == nil {
sublog.Debug().Msg("stat did not include a space, executing an additional lookup request")
// TODO look up space? hm can the isShared check even work when stating a space? hm yeah ... well ... *mindblown*
// fake a space root
space = &provider.StorageSpace{
Id: &provider.StorageSpaceId{OpaqueId: spaceID},
Expand Down Expand Up @@ -672,9 +671,6 @@ func (p *Handler) getSpaceResourceInfos(ctx context.Context, w http.ResponseWrit

metadataKeys, _ := metadataKeys(pf)

// we need to prefix the path with / to make subsequent prefix matches work
// info.Path = filepath.Join("/", spaceRef.Path)

resourceInfos := []*provider.ResourceInfo{}

req := &provider.ListContainerRequest{
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *svc) doFilterFiles(w http.ResponseWriter, r *http.Request, ff *reportFi
infos = append(infos, statRes.Info)
}

responsesXML, err := propfind.MultistatusResponse(ctx, &propfind.XML{Prop: ff.Prop}, infos, s.c.PublicURL, namespace /*"",*/, nil)
responsesXML, err := propfind.MultistatusResponse(ctx, &propfind.XML{Prop: ff.Prop}, infos, s.c.PublicURL, namespace, nil)
if err != nil {
log.Error().Err(err).Msg("error formatting propfind")
w.WriteHeader(http.StatusInternalServerError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ func LookUpStorageSpacesForPathWithChildren(ctx context.Context, client gateway.
// TODO use ListContainerStream to listen for changes
// retrieve a specific storage space
lSSReq := &storageProvider.ListStorageSpacesRequest{
Opaque: &typesv1beta1.Opaque{
Map: map[string]*typesv1beta1.OpaqueEntry{
// TODO encode requested metadata as json
// "metadata": {Decoder: "json", Value: []byte("*")},
}},
// get all fields, including root_info
FieldMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
infos = append(infos, vi)
}

propRes, err := propfind.MultistatusResponse(ctx, &pf, infos, s.c.PublicURL, "" /*"",*/, nil)
propRes, err := propfind.MultistatusResponse(ctx, &pf, infos, s.c.PublicURL, "", nil)
if err != nil {
sublog.Error().Err(err).Msg("error formatting propfind")
w.WriteHeader(http.StatusInternalServerError)
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (fs *Decomposedfs) CreateDir(ctx context.Context, ref *provider.Reference)
if n, err = fs.lu.NodeFromResource(ctx, parentRef); err != nil {
return
}
// TODO check if user has access to root / space
if !n.Exists {
return errtypes.PreconditionFailed(parentRef.Path)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,15 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string, canLis
}
r.Exists = true

// TODO ReadNode should not check permissions
if !canListDisabledSpace && r.IsDisabled() {
// no permission = not found
return nil, errtypes.NotFound(spaceID)
}

// if current user cannot stat the root return not found?
// no for shares the root might be a different resource

// check if this is a space root
if spaceID == nodeID {
return r, nil
Expand Down
9 changes: 1 addition & 8 deletions pkg/storage/utils/decomposedfs/node/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,6 @@ func (p *Permissions) HasPermission(ctx context.Context, n *Node, check func(*pr
return check(perms), nil
}

// determine root
/*
if err = n.FindStorageSpaceRoot(); err != nil {
return false, err
}
*/

// for an efficient group lookup convert the list of groups to a map
// groups are just strings ... groupnames ... or group ids ??? AAARGH !!!
groupsMap := make(map[string]bool, len(u.Groups))
Expand All @@ -207,7 +200,7 @@ func (p *Permissions) HasPermission(ctx context.Context, n *Node, check func(*pr
}
}

// also check permissions on root, eg. for for project spaces
// also check permissions on root, eg. for project spaces
return nodeHasPermission(ctx, cn, groupsMap, u.Id.OpaqueId, check), nil
}

Expand Down

0 comments on commit a40f558

Please sign in to comment.