Bump reva

This commit is contained in:
André Duffeck
2023-10-18 18:14:16 +02:00
parent b3a92548b7
commit 0b10285dd6
5 changed files with 38 additions and 19 deletions

View File

@@ -805,19 +805,18 @@ func (m *Manager) ListReceivedShares(ctx context.Context, filters []*collaborati
}
// add all spaces the user has receved shares for, this includes mount points and share state for groups
// TODO: rewrite this code to not use the internal strucs anymore (e.g. by adding a List method). Sync can then be made private.
_ = m.UserReceivedStates.Sync(ctx, user.Id.OpaqueId) // ignore error, cache will be updated on next read
if m.UserReceivedStates.ReceivedSpaces[user.Id.OpaqueId] != nil {
for ssid, rspace := range m.UserReceivedStates.ReceivedSpaces[user.Id.OpaqueId].Spaces {
if rs, ok := ssids[ssid]; ok {
for shareid, state := range rspace.States {
// overwrite state
rs.States[shareid] = state
}
} else {
ssids[ssid] = rspace
spaces, err := m.UserReceivedStates.List(ctx, user.Id.OpaqueId)
if err != nil {
return nil, err
}
for ssid, rspace := range spaces {
if rs, ok := ssids[ssid]; ok {
for shareid, state := range rspace.States {
// overwrite state
rs.States[shareid] = state
}
} else {
ssids[ssid] = rspace
}
}

View File

@@ -177,15 +177,35 @@ func (c *Cache) Get(ctx context.Context, userID, spaceID, shareID string) (*Stat
return c.ReceivedSpaces[userID].Spaces[spaceID].States[shareID], nil
}
// Sync updates the in-memory data with the data from the storage if it is outdated
func (c *Cache) Sync(ctx context.Context, userID string) error {
// List returns a list of received shares for a given user
// The return list is guaranteed to be thread-safe
func (c *Cache) List(ctx context.Context, userID string) (map[string]*Space, error) {
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Grab lock")
unlock := c.lockUser(userID)
span.End()
span.SetAttributes(attribute.String("cs3.userid", userID))
defer unlock()
return c.syncWithLock(ctx, userID)
err := c.syncWithLock(ctx, userID)
if err != nil {
return nil, err
}
spaces := map[string]*Space{}
for spaceID, space := range c.ReceivedSpaces[userID].Spaces {
spaceCopy := &Space{
States: map[string]*State{},
}
for shareID, state := range space.States {
spaceCopy.States[shareID] = &State{
State: state.State,
MountPoint: state.MountPoint,
Hide: state.Hide,
}
}
spaces[spaceID] = spaceCopy
}
return spaces, nil
}
func (c *Cache) syncWithLock(ctx context.Context, userID string) error {