Skip to content

Commit

Permalink
Implement Dump() for the cs3 publicshare manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Sep 9, 2022
1 parent 057b14c commit 7d12864
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/publicshare/manager/cs3/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,32 @@ func (m *Manager) initialize() error {
return nil
}

// Dump exports public shares to channels (e.g. during migration)
func (m *Manager) Dump(ctx context.Context, shareChan chan<- *publicshare.WithPassword) error {
if err := m.initialize(); err != nil {
return err
}

pshares, err := m.storage.ListDir(ctx, "publicshares")
if err != nil {
return err
}

for _, v := range pshares {
var local publicshare.WithPassword
ps, err := m.getByToken(ctx, v.Name)
if err != nil {
return err
}
local.Password = ps.Password
local.PublicShare = ps.PublicShare

shareChan <- &local
}

return nil
}

// Load imports public shares and received shares from channels (e.g. during migration)
func (m *Manager) Load(ctx context.Context, shareChan <-chan *publicshare.WithPassword) error {
log := appctx.GetLogger(ctx)
Expand Down

0 comments on commit 7d12864

Please sign in to comment.