Skip to content

Commit

Permalink
non personal spaces need virtual owner
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Jul 26, 2022
1 parent ec605be commit 6ab8cd4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/space-owner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Project spaces need no real owner

Make it possible to use a non existing user as a space owner.

https://github.com/cs3org/reva/pull/3091
Original file line number Diff line number Diff line change
Expand Up @@ -1119,30 +1119,33 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf
// TODO log error?
s.Path = gpRes.Path
}

// cut off configured home namespace, paths in ocs shares are relative to it
identifier := h.mustGetIdentifiers(ctx, client, info.GetOwner().GetOpaqueId(), false)
u := &userpb.User{
Id: info.Owner,
Username: identifier.Username,
DisplayName: identifier.DisplayName,
Mail: identifier.Mail,
// on spaces, we could have no owner set
if info.Owner != nil {
// cut off configured home namespace, paths in ocs shares are relative to it
identifier := h.mustGetIdentifiers(ctx, client, info.GetOwner().GetOpaqueId(), false)
u := &userpb.User{
Id: info.Owner,
Username: identifier.Username,
DisplayName: identifier.DisplayName,
Mail: identifier.Mail,
}
s.Path = strings.TrimPrefix(s.Path, h.getHomeNamespace(u))
}
s.Path = strings.TrimPrefix(s.Path, h.getHomeNamespace(u))
}
}
s.StorageID = storageIDPrefix + s.FileTarget
// TODO FileParent:
// item type
s.ItemType = conversions.ResourceType(info.GetType()).String()

owner := info.GetOwner()
// file owner might not yet be set. Use file info
if s.UIDFileOwner == "" {
s.UIDFileOwner = info.GetOwner().GetOpaqueId()
if s.UIDFileOwner == "" && owner != nil {
s.UIDFileOwner = owner.GetOpaqueId()
}
// share owner might not yet be set. Use file info
if s.UIDOwner == "" {
s.UIDOwner = info.GetOwner().GetOpaqueId()
if s.UIDOwner == "" && owner != nil {
s.UIDOwner = owner.GetOpaqueId()
}
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions pkg/publicshare/manager/cs3/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ func (m *Manager) CreatePublicShare(ctx context.Context, u *user.User, ri *provi
Password: password,
}

// spaces have no owner, use creator
if s.PublicShare.GetOwner() == nil {
s.PublicShare.Owner = u.Id
}

err := m.persist(ctx, s)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions pkg/publicshare/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
Password: password,
}

// spaces have no owner, use creator
if ps.PublicShare.GetOwner() == nil {
ps.PublicShare.Owner = u.Id
}

m.mutex.Lock()
defer m.mutex.Unlock()

Expand Down
5 changes: 5 additions & 0 deletions pkg/publicshare/manager/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
DisplayName: displayName,
}

// spaces have no owner, use creator
if s.GetOwner() == nil {
s.Owner = u.Id
}

m.shares.Store(s.Token, &s)
return &s, nil
}
Expand Down

0 comments on commit 6ab8cd4

Please sign in to comment.