mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-09-08 15:36:24 +08:00
fixed total parts calculation
This commit is contained in:
parent
2b08b57ebf
commit
73bd58d81a
1 changed files with 1 additions and 13 deletions
|
@ -513,25 +513,13 @@ func chunk(ctx context.Context, tgClient *telegram.Client, part *types.Part, off
|
|||
}
|
||||
}
|
||||
|
||||
func totalParts(start, end, chunkSize int64) int {
|
||||
|
||||
totalBytes := end - start + 1
|
||||
parts := totalBytes / chunkSize
|
||||
|
||||
if totalBytes%chunkSize != 0 {
|
||||
parts++
|
||||
}
|
||||
|
||||
return int(parts)
|
||||
}
|
||||
|
||||
func streamFilePart(ctx context.Context, tgClient *telegram.Client, writer *io.PipeWriter, part *types.Part, start, end, chunkSize int64) error {
|
||||
|
||||
offset := start - (start % chunkSize)
|
||||
firstPartCut := start - offset
|
||||
lastPartCut := (end % chunkSize) + 1
|
||||
|
||||
partCount := totalParts(start, end, chunkSize)
|
||||
partCount := int(math.Ceil(float64(end+1)/float64(chunkSize))) - int(math.Floor(float64(offset)/float64(chunkSize)))
|
||||
|
||||
currentPart := 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue