]> Sergey Matveev's repositories - btrtrc.git/commitdiff
sqlite storage: Ensure that chunks are consecutive
authorMatt Joiner <anacrolix@gmail.com>
Sat, 21 Nov 2020 02:39:04 +0000 (13:39 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 21 Nov 2020 02:44:23 +0000 (13:44 +1100)
storage/sqlite/sqlite-storage.go

index 2f58883ae58f87bb24877012dc7c3fe7155997e0..22b4b8fd071f91e573ca06938da45a4bcfddc2ed 100644 (file)
@@ -319,9 +319,11 @@ func (p *provider) WriteConsecutiveChunks(prefix string, w io.Writer) (written i
                                where name like ?||'%'
                                order by offset`,
                        func(stmt *sqlite.Stmt) error {
+                               offset := stmt.ColumnInt64(1)
+                               if offset != written {
+                                       return fmt.Errorf("got chunk at offset %v, expected offset %v", offset, written)
+                               }
                                r := stmt.ColumnReader(0)
-                               //offset := stmt.ColumnInt64(1)
-                               //log.Printf("got %v bytes at offset %v", r.Len(), offset)
                                w1, err := io.Copy(w, r)
                                written += w1
                                return err