diff --git a/changelog/unreleased/dump-cs3-publicsharemanager.md b/changelog/unreleased/dump-cs3-publicsharemanager.md new file mode 100644 index 0000000000..42ad83b4c9 --- /dev/null +++ b/changelog/unreleased/dump-cs3-publicsharemanager.md @@ -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 diff --git a/pkg/publicshare/manager/cs3/cs3.go b/pkg/publicshare/manager/cs3/cs3.go index 60029442b1..6383f24220 100644 --- a/pkg/publicshare/manager/cs3/cs3.go +++ b/pkg/publicshare/manager/cs3/cs3.go @@ -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)