Skip to content

Conversation

@Sunday-Crunk
Copy link
Contributor

@Sunday-Crunk Sunday-Crunk commented Sep 19, 2025

Fix checksum worker parameter passing and PydioApi method calls

  • Move PydioApi calls from worker to WorkerManager to fix worker context issues
  • Correct PydioApi.getMultipartPartSize() to getMultipartThreshold() for threshold check
  • Pass multipartThreshold and multipartPartSize as parameters to worker
  • Re-add incrementalMD5 implementation for single-file checksum calculation
  • Use proper multipartPartSize for calculateMultipartChecksum function

Summary by CodeRabbit

  • New Features

    • Improved file hashing performance and reliability for both small and large uploads.
    • More efficient handling of large files through size-aware multipart hashing.
  • Refactor

    • Streamlined worker communication by passing size parameters directly.
    • Simplified hashing worker behavior and cleanup; reduced console noise.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Extends WorkerManager to send multipartThreshold and multipartPartSize to the hash worker. The worker refactors hashing: imports SparkMD5 via importScripts, adds incremental MD5 for small files, and uses calculateMultipartChecksum with multipartPartSize for large files. Message handling updated to consume the new parameters and return results or errors.

Changes

Cohort / File(s) Summary of Changes
Core worker messaging
src/js/core/WorkerManager.js
Adds multipartThreshold and multipartPartSize to postMessage arguments in processNextTask.
Hash worker refactor & hashing paths
src/js/workers/hashWorker.worker.js
Switches to importScripts for SparkMD5; introduces incrementalMD5 (2MB chunking) for small files; updates message handling to read multipartThreshold and multipartPartSize; routes large files to calculateMultipartChecksum(file, multipartPartSize); cleans logs; ensures result/error postMessage and self-close.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant WM as WorkerManager
  participant HW as hashWorker.worker

  WM->>HW: postMessage({ file, msg:"begin hash", multipartThreshold, multipartPartSize })
  Note right of HW: Receives thresholds and sizes from message

  alt file.size < multipartThreshold
    rect rgba(200,240,255,0.2)
    note over HW: Small file path
    HW->>HW: incrementalMD5(file)<br/>(FileReader 2MB chunks + SparkMD5.ArrayBuffer)
    end
  else file.size >= multipartThreshold
    rect rgba(220,255,200,0.2)
    note over HW: Large file path
    HW->>HW: calculateMultipartChecksum(file, multipartPartSize)
    end
  end

  HW-->>WM: postMessage({ hash | error })
  HW->>HW: self.close()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I nibble bytes in tidy chews,
Two meg crumbs and hashing news—
Small snacks sparkle, big ones split,
Parts parade till checksums fit.
With thresholds packed, I thump in glee,
A worker hops, then sets code free. 🥕🐇

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev/checksum-generation-fix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0d97e0 and feedb70.

📒 Files selected for processing (2)
  • src/js/core/WorkerManager.js (1 hunks)
  • src/js/workers/hashWorker.worker.js (2 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sunday-Crunk Sunday-Crunk merged commit 22c9902 into main Sep 19, 2025
1 check was pending
@Sunday-Crunk Sunday-Crunk deleted the dev/checksum-generation-fix branch September 19, 2025 12:43
@coderabbitai coderabbitai bot mentioned this pull request Sep 21, 2025
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.

2 participants