-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
132 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package transform | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/fs" | ||
"path/filepath" | ||
"runtime/trace" | ||
|
||
"github.com/rusq/dlog" | ||
"github.com/rusq/fsadapter" | ||
"github.com/rusq/slackdump/v2/internal/chunk/state" | ||
) | ||
|
||
// Reconstruct reconstructs the conversation files from the temporary directory | ||
// with state files and chunk records. | ||
func Reconstruct(ctx context.Context, fsa fsadapter.FS, tmpdir string, tf Interface) error { | ||
_, task := trace.NewTask(ctx, "reconstruct") | ||
defer task.End() | ||
|
||
return filepath.WalkDir(tmpdir, func(path string, d fs.DirEntry, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if d.IsDir() { | ||
if path != tmpdir { | ||
return filepath.SkipDir | ||
} | ||
return nil | ||
} | ||
if filepath.Ext(path) != ".state" { | ||
return nil | ||
} | ||
|
||
st, err := state.Load(path) | ||
if err != nil { | ||
return fmt.Errorf("failed to load state file: %w", err) | ||
} | ||
|
||
dlog.Printf("reconstructing %s", st.Filename) | ||
return tf.Transform(ctx, tmpdir, st) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package transform | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/rusq/slackdump/v2/internal/chunk/state" | ||
) | ||
|
||
type Interface interface { | ||
// Transform transforms the conversation files from the temporary directory | ||
// with state files and chunk records. | ||
Transform(ctx context.Context, basePath string, st *state.State) error | ||
} |