Skip to content

Commit

Permalink
fix file download location and duplicate detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Apr 29, 2023
1 parent aacfe94 commit 7aa5f24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ func (c *Client) startWorkers(ctx context.Context, req <-chan Request) *sync.Wai
if c.workers == 0 {
c.workers = defNumWorkers
}
seen := fltSeen(req)
var wg sync.WaitGroup
// create workers
for i := 0; i < c.workers; i++ {
wg.Add(1)
go func(workerNum int) {
c.worker(ctx, fltSeen(req))
c.worker(ctx, seen)
wg.Done()
c.lg.Debugf("download worker %d terminated", workerNum)
}(i)
Expand Down
8 changes: 4 additions & 4 deletions internal/chunk/transform/subproc/sp_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (d DumpSubproc) Files(ctx context.Context, channel *slack.Channel, m slack.
if !isDownloadable(&f) {
continue
}
if err := d.dcl.Download(d.filepath(channel.ID, m.ThreadTimestamp, &f), f.URLPrivateDownload); err != nil {
if err := d.dcl.Download(d.filepath(channel.ID, &f), f.URLPrivateDownload); err != nil {
return err
}
}
Expand All @@ -42,7 +42,7 @@ func (d DumpSubproc) Files(ctx context.Context, channel *slack.Channel, m slack.
func (d DumpSubproc) PathUpdateFunc(channelID, threadTS string, mm []slack.Message) error {
for i := range mm {
for j := range mm[i].Files {
path := d.filepath(channelID, threadTS, &mm[i].Files[j])
path := d.filepath(channelID, &mm[i].Files[j])
if err := files.UpdatePathFn(path)(&mm[i].Files[j]); err != nil {
return err
}
Expand All @@ -51,6 +51,6 @@ func (d DumpSubproc) PathUpdateFunc(channelID, threadTS string, mm []slack.Messa
return nil
}

func (d DumpSubproc) filepath(channelID, threadTS string, f *slack.File) string {
return filepath.Join(chunk.ToFileID(channelID, threadTS, true).String(), f.ID+"-"+f.Name)
func (d DumpSubproc) filepath(channelID string, f *slack.File) string {
return filepath.Join(chunk.ToFileID(channelID, "", false).String(), f.ID+"-"+f.Name)
}

0 comments on commit 7aa5f24

Please sign in to comment.