Skip to content

Commit

Permalink
Remove states for shares that no longer exist
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Dec 2, 2024
1 parent 1c950c7 commit c2f0b09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pkg/share/manager/jsoncs3/jsoncs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,13 @@ func (m *Manager) ListReceivedShares(ctx context.Context, filters []*collaborati
}
for shareID, state := range w.rspace.States {
s, err := m.Cache.Get(ctx, storageID, spaceID, shareID, true)
if err != nil || s == nil {
if err != nil {
sublogr.Error().Err(err).Msg("could not retrieve share")
continue
}
if s == nil {
sublogr.Warn().Str("shareid", shareID).Msg("share not found. cleaning up")
_ = m.UserReceivedStates.Remove(ctx, user.Id.OpaqueId, w.ssid, shareID)
continue
}
sublogr = sublogr.With().Str("shareid", shareID).Logger()
Expand Down
6 changes: 5 additions & 1 deletion pkg/share/manager/jsoncs3/providercache/providercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ func (c *Cache) PurgeSpace(ctx context.Context, storageID, spaceID string) error
if !ok {
return nil
}
spaces.Spaces.Store(spaceID, &Shares{})
newShares := &Shares{}
if space, ok := spaces.Spaces.Load(spaceID); ok {
newShares.Etag = space.Etag // keep the etag to allow overwriting the state on the server
}
spaces.Spaces.Store(spaceID, newShares)

return c.Persist(ctx, storageID, spaceID)
}
Expand Down

0 comments on commit c2f0b09

Please sign in to comment.