|
@@ -310,11 +310,18 @@ func (*DB) insertBlocksLocked(tx *txPreparedStmts, blocklistHash []byte, blocks
|
|
"size": b.Size,
|
|
"size": b.Size,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- _, err := tx.NamedExec(`
|
|
|
|
- INSERT OR IGNORE INTO blocks (hash, blocklist_hash, idx, offset, size)
|
|
|
|
- VALUES (:hash, :blocklist_hash, :idx, :offset, :size)
|
|
|
|
- `, bs)
|
|
|
|
- return wrap(err)
|
|
|
|
|
|
+
|
|
|
|
+ // Very large block lists (>8000 blocks) result in "too many variables"
|
|
|
|
+ // error. Chunk it to a reasonable size.
|
|
|
|
+ for chunk := range slices.Chunk(bs, 1000) {
|
|
|
|
+ if _, err := tx.NamedExec(`
|
|
|
|
+ INSERT OR IGNORE INTO blocks (hash, blocklist_hash, idx, offset, size)
|
|
|
|
+ VALUES (:hash, :blocklist_hash, :idx, :offset, :size)
|
|
|
|
+ `, chunk); err != nil {
|
|
|
|
+ return wrap(err)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DB) recalcGlobalForFolder(txp *txPreparedStmts, folderIdx int64) error {
|
|
func (s *DB) recalcGlobalForFolder(txp *txPreparedStmts, folderIdx int64) error {
|