Skip to content

fix: align PAR2 slice size to multiple of 4 as required by spec#200

Merged
javi11 merged 1 commit intomainfrom
fix/par2-slice-size-alignment
Apr 11, 2026
Merged

fix: align PAR2 slice size to multiple of 4 as required by spec#200
javi11 merged 1 commit intomainfrom
fix/par2-slice-size-alignment

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented Apr 11, 2026

Summary

  • Fix PAR2 creation failing with par2go: SliceSize must be a positive multiple of 4, got 361254
  • calculateParBlockSize() now always returns a value aligned to a multiple of 4
  • Extract maxPar2Blocks constant (was magic number 32768) from the PAR2 spec
  • Add belt-and-suspenders alignment guard in createPar2ForFile() before calling par2go.Create()

Root Cause

articleSize (from posting.article_size_in_bytes) is not guaranteed to be a multiple of 4. When the file was larger than articleSize, the existing SIMD alignment guard never triggered, so the unaligned value was passed directly to par2go.Create() which rejected it.

Related #198

The par2go library requires SliceSize to be a positive multiple of 4.
When articleSize (from posting config) was not a multiple of 4,
calculateParBlockSize returned it unaligned, causing par2 creation to
fail with "SliceSize must be a positive multiple of 4".

Extract maxPar2Blocks constant, add alignDown helper, and ensure all
code paths produce a spec-compliant block size.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@javi11 javi11 merged commit ea084f8 into main Apr 11, 2026
3 checks passed
@javi11 javi11 deleted the fix/par2-slice-size-alignment branch April 11, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant