Skip to content

fix: refactor use natives to drop md5-file and multistream#888

Merged
ferhatelmas merged 1 commit intomasterfrom
ferhat/md5-multistream
Mar 6, 2026
Merged

fix: refactor use natives to drop md5-file and multistream#888
ferhatelmas merged 1 commit intomasterfrom
ferhat/md5-multistream

Conversation

@ferhatelmas
Copy link
Member

What kind of change does this PR introduce?

Refactor

What is the current behavior?

Using three dependencies for file-backend (md5-file, multistream and its types).

What is the new behavior?

They can be replaced with their native counterparts (crypto.createHash and Readable.from).

Additional context

Less dependencies, less surface.

@ferhatelmas ferhatelmas requested a review from a team as a code owner March 4, 2026 09:35
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: fe0b2cd6-c8fb-4025-87e0-57480f5875bf

📥 Commits

Reviewing files that changed from the base of the PR and between feb370c and 9e34653.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json
  • src/storage/backend/file.ts
💤 Files with no reviewable changes (1)
  • package.json

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Removed two runtime dependencies and replaced their functionality with internal implementations.
    • Consolidated streaming and checksum handling into a unified internal flow.
    • Updated multipart upload internals to use the new helpers.
    • No changes to public APIs or end-user behavior.

Walkthrough

This PR removes runtime dependencies "md5-file" and "multistream" from the file storage backend by internalizing MD5 hashing and multipart stream merging. It adds private helpers computeMd5, iteratePartChunks, and mergePartStreams, replaces external calls with these helpers, and updates multipart upload flows to pass the produced multipart stream and computed ETag. No exported/public API signatures changed.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant StorageBackend
    participant FileSystem
    participant Crypto
    participant UploadService
    participant ObjectStore

    Client->>StorageBackend: Request multipart upload (finalParts)
    StorageBackend->>FileSystem: Open part files (create ReadStreams)
    StorageBackend->>Crypto: computeMd5(partPath) for ETag
    Crypto-->>StorageBackend: MD5 hash
    StorageBackend->>StorageBackend: mergePartStreams(finalParts) -> multipartStream
    StorageBackend->>UploadService: uploadObject(name, multipartStream, etag)
    UploadService->>ObjectStore: stream data -> store object
    ObjectStore-->>UploadService: upload result
    UploadService-->>StorageBackend: upload result
    StorageBackend-->>Client: Finalize response
Loading

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.

@ferhatelmas ferhatelmas force-pushed the ferhat/md5-multistream branch 2 times, most recently from 447ec0a to feb370c Compare March 5, 2026 10:24
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
@ferhatelmas ferhatelmas force-pushed the ferhat/md5-multistream branch from feb370c to 9e34653 Compare March 6, 2026 09:45
@ferhatelmas ferhatelmas merged commit 722e37b into master Mar 6, 2026
4 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/md5-multistream branch March 6, 2026 09:57
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.

4 participants