Skip to content

Commit

Permalink
filter external files #206
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Apr 13, 2023
1 parent 2f1cec0 commit 684fc94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ func (c *Client) saveFile(ctx context.Context, dir string, sf *slack.File) (int6
if c.fs == nil {
return 0, ErrNoFS
}
if mode := sf.Mode; mode == "hidden_by_limit" || mode == "external" || sf.IsExternal {
trace.Logf(ctx, "info", "file %q is not downloadable", sf.Name)
return 0, nil
}
filePath := filepath.Join(dir, c.nameFn(sf))

tf, err := os.CreateTemp("", "")
Expand Down
4 changes: 2 additions & 2 deletions internal/chunk/processor/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func (s *Standard) Files(ctx context.Context, channelID string, parent slack.Mes
}
// custom file processor, because we need to donwload those files
for i := range ff {
if ff[i].Mode == "hidden_by_limit" {
if mode := ff[i].Mode; mode == "hidden_by_limit" || mode == "external" || ff[i].IsExternal {
// ignore files that are hidden by the limit
trace.Logf(ctx, "skip", "file hidden by limit: %q", ff[i].ID)
trace.Logf(ctx, "skip", "unfetchable file type: %q", ff[i].ID)
continue
}
filename, err := s.dl.DownloadFile(channelID, ff[i])
Expand Down

0 comments on commit 684fc94

Please sign in to comment.