Skip to content

Commit

Permalink
Merge pull request #3213 from aduffeck/dump-cs3-publishare-manager
Browse files Browse the repository at this point in the history
Dump cs3 publicshare manager
  • Loading branch information
micbar authored Sep 9, 2022
2 parents 057b14c + dd7b442 commit 22e6b32
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/dump-cs3-publicsharemanager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Allow for dumping the public shares from the cs3 publicshare manager

We enhanced the cs3 publicshare manager to support dumping its content during a publicshare manager migration.

https://github.com/cs3org/reva/pull/3213
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 22e6b32

Please sign in to comment.