瀏覽代碼

Fix `GenericDownloadIter` offset bug (#475)

`bad` variable should have been calculated with modulo not division. Fixes https://github.com/gram-js/gramjs/issues/465
Mohammad Momeni 2 年之前
父節點
當前提交
78979a07a1
共有 1 個文件被更改,包括 1 次插入3 次删除
  1. 1 3
      gramjs/client/downloads.ts

+ 1 - 3
gramjs/client/downloads.ts

@@ -232,9 +232,7 @@ export class GenericDownloadIter extends DirectDownloadIter {
         let data = Buffer.alloc(0);
 
         //  1.1. ``bad`` is how much into the data we have we need to offset
-        const bad = this.request!.offset.divide(
-            this.request!.limit
-        ).toJSNumber();
+        const bad = this.request!.offset.mod(this.request!.limit).toJSNumber()
         const before = this.request!.offset;
 
         // 1.2. We have to fetch from a valid offset, so remove that bad part