Skip to content

Commit

Permalink
refactor: uncomment worker termination logic in UploadFile and Downlo…
Browse files Browse the repository at this point in the history
…adChunk methods
  • Loading branch information
AmarnathCJD committed Jan 18, 2025
1 parent 6c92b4e commit 9af04e2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions telegram/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ func (c *Client) UploadFile(src any, Opts ...*UploadOptions) (InputFile, error)
}

// destroy created workers
// for _, worker := range w.workers {
// worker.Terminate()
// }
for _, worker := range w.workers {
worker.Terminate()
}

if opts.FileName != "" {
fileName = opts.FileName
Expand Down Expand Up @@ -636,9 +636,9 @@ retrySinglePart:
}

// destroy created workers
// for _, worker := range w.workers {
// worker.Terminate()
// }
for _, worker := range w.workers {
worker.Terminate()
}

return dest, nil
}
Expand Down Expand Up @@ -669,14 +669,14 @@ func initializeWorkers(numWorkers int, dc int32, c *Client, w *WorkerPool) {
}

numCreate := 0
for dcId, workers := range c.exSenders {
if int(dc) == dcId {
for _, worker := range workers {
w.AddWorker(worker)
numCreate++
}
}
}
// for dcId, workers := range c.exSenders {
// if int(dc) == dcId {
// for _, worker := range workers {
// w.AddWorker(worker)
// numCreate++
// }
// }
// }

for i := numCreate; i < numWorkers; i++ {
conn, err := c.CreateExportedSender(int(dc), false, authParams)
Expand Down Expand Up @@ -711,7 +711,7 @@ func (c *Client) DownloadChunk(media any, start int, end int, chunkSize int) ([]
end = int(size)
}

sender, err := c.CreateExportedSender(int(dc), false)
sender, err := c.CreateExportedSender(int(dc), false) // cache this for efficiency, TODO
if err != nil {
return nil, "", err
}
Expand Down

0 comments on commit 9af04e2

Please sign in to comment.