Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Mar 13, 2023
1 parent efcc5a3 commit 0cde4f2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
48 changes: 48 additions & 0 deletions internal/chunk/transform/export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package transform

import (
"archive/zip"
"fmt"
"path"

"github.com/rusq/slackdump/v2/export"
"github.com/rusq/slackdump/v2/internal/chunk/state"
)

type Export struct{}

func NewExport() *Export { return &Export{} }

type ExportInfo struct {
IsComplete bool
State *state.State
ExportType export.ExportType
Filename string
}

func (e *Export) RestoreState(loc string) (*state.State, error) {
zf, err := zip.OpenReader(loc)
if err != nil {
return nil, err
}
defer zf.Close()

var ei = ExportInfo{
State: state.New(""),
}

for _, f := range zf.File {
switch path.Base(f.Name) {
case "channels.json":
case "mpims.json":
case "dms.json":
case "users.jsone":
ei.IsComplete = true
default:
// TODO: handle other files
}
fmt.Println(path.Split(f.Name))
}

return nil, nil
}
16 changes: 16 additions & 0 deletions internal/chunk/transform/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package transform

import (
"testing"
)

func TestExport_RestoreState(t *testing.T) {
t.Run("manual", func(t *testing.T) {
e := NewExport()
_, err := e.RestoreState("../../../tmp/kiwi1.zip")
if err != nil {
t.Fatal(err)
}
t.Error("x")
})
}

0 comments on commit 0cde4f2

Please sign in to comment.