Skip to content

Commit

Permalink
Merge pull request #2994 from aduffeck/fix-loading-shares
Browse files Browse the repository at this point in the history
Fix loading shares
  • Loading branch information
aduffeck committed Jun 21, 2022
2 parents 6a34667 + fd618ce commit 3a341c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit 3a341c3

Please sign in to comment.