-
-
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
14 changed files
with
141 additions
and
123 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 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
// Package expproc implements the export processor interface. The processor | ||
// is responsible for writing the data to disk. | ||
// is responsible for writing the data to disk. It does many things | ||
// concurrently. | ||
// | ||
// GOOD LUCK DEBUGGING THIS. | ||
package expproc | ||
|
||
const ext = ".jsonl.gz" |
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,75 @@ | ||
package expproc | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/rusq/slackdump/v2/downloader" | ||
"github.com/rusq/slackdump/v2/export" | ||
"github.com/rusq/slackdump/v2/internal/chunk/processor" | ||
"github.com/slack-go/slack" | ||
) | ||
|
||
// Filer initialises a filer type based on the given export type. | ||
// This filer can be later plugged into the Conversations processor using | ||
// WithFiler option. | ||
func NewFiler(typ export.ExportType, dl *downloader.Client) processor.Filer { | ||
switch typ { | ||
case export.TStandard: | ||
return stdfiler{ | ||
basefiler: basefiler{ | ||
dcl: dl, | ||
}, | ||
} | ||
case export.TMattermost: | ||
return mmfiler{ | ||
basefiler: basefiler{ | ||
dcl: dl, | ||
}, | ||
} | ||
default: | ||
return nopfiler{} | ||
} | ||
} | ||
|
||
type basefiler struct { | ||
dcl *downloader.Client | ||
} | ||
|
||
type mmfiler struct { | ||
basefiler | ||
} | ||
|
||
func (mm mmfiler) Files(ctx context.Context, channelID string, parent slack.Message, isThread bool, ff []slack.File) error { | ||
const baseDir = "__uploads" | ||
for _, f := range ff { | ||
if err := mm.dcl.Download(filepath.Join(baseDir, f.ID, f.Name), f.URLPrivateDownload); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
type nopfiler struct{} | ||
|
||
func (nopfiler) Files(ctx context.Context, channelID string, parent slack.Message, isThread bool, ff []slack.File) error { | ||
return nil | ||
} | ||
|
||
type stdfiler struct { | ||
basefiler | ||
} | ||
|
||
func (mm stdfiler) Files(ctx context.Context, channelID string, parent slack.Message, isThread bool, ff []slack.File) error { | ||
const baseDir = "attachments" | ||
for _, f := range ff { | ||
if err := mm.dcl.Download( | ||
filepath.Join(channelID, baseDir, fmt.Sprintf("%s-%s", f.ID, f.Name)), | ||
f.URLPrivateDownload, | ||
); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
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
Oops, something went wrong.