Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading shares #2994

Merged
merged 3 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-loading-shares.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix errors when loading shares

We fixed a bug where loading shares and associated received shares ran into issues when handling them simultaneously.

https://github.com/cs3org/reva/pull/2994
5 changes: 5 additions & 0 deletions pkg/share/manager/cs3/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,30 @@ func (m *Manager) Load(ctx context.Context, shareChan <-chan *collaboration.Shar
return err
}

var mu sync.Mutex
var wg sync.WaitGroup
wg.Add(2)
go func() {
for s := range shareChan {
if s == nil {
continue
}
mu.Lock()
if err := m.persistShare(context.Background(), s); err != nil {
log.Error().Err(err).Interface("share", s).Msg("error persisting share")
}
mu.Unlock()
}
wg.Done()
}()
go func() {
for s := range receivedShareChan {
if s.ReceivedShare != nil && s.UserID != nil {
mu.Lock()
if err := m.persistReceivedShare(context.Background(), s.UserID, s.ReceivedShare); err != nil {
log.Error().Err(err).Interface("received share", s).Msg("error persisting received share")
}
mu.Unlock()
}
}
wg.Done()
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (fs *Decomposedfs) CreateDir(ctx context.Context, ref *provider.Reference)
return
}
if n.Exists {
return errtypes.AlreadyExists(parentRef.Path)
return errtypes.AlreadyExists(ref.Path)
}

if err = fs.tp.CreateDir(ctx, n); err != nil {
Expand Down