Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve data parsing for unstorage #204

Merged
merged 15 commits into from
Jan 11, 2024

Conversation

Aareksio
Copy link
Contributor

@Aareksio Aareksio commented Jan 6, 2024

πŸ”— Linked issue

nuxt/image#1177

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The prefix should not be required.

unstorage is not opinionated about what data type should getItem / getItemRaw return (unjs/unstorage#142). This making creating generic wrapper a bit complicated. Since ipx requires the data to be a Buffer, I've added a simple parse attempt in order to normalize error for unsupported storages. The common return data types should be covered: ArrayBuffer, Buffer, String and Blob.


I also found some inconsistencies in unstorage drivers, namely http driver throws 404 when a file is not found, instead of returning null which seems to be unstorage convention. This breaks the test. I classify this as a bug in unstorage and keep the test disabled. Run TEST_UNSTORAGE_HTTP=true pnpm test to see the error.

Screenshot 2024-01-06 at 13 31 47

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Unstorage support is not documented yet

@Aareksio Aareksio changed the title fix(unstorage): actually implement unstorage driver feat(unstorage): improve data parsing Jan 6, 2024
@pi0 pi0 changed the title feat(unstorage): improve data parsing fix: improve data parsing for unstorage Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (39c7199) 50.73% compared to head (7df105c) 53.66%.

❗ Current head 7df105c differs from pull request most recent head aefac26. Consider uploading reports for the commit aefac26 to get more accurate results

Files Patch % Lines
src/storage/unstorage.ts 80.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
+ Coverage   50.73%   53.66%   +2.93%     
==========================================
  Files          14       14              
  Lines        1157     1187      +30     
  Branches       48       66      +18     
==========================================
+ Hits          587      637      +50     
+ Misses        567      547      -20     
  Partials        3        3              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0 pi0 merged commit be4b092 into unjs:main Jan 11, 2024
2 checks passed
@pi0
Copy link
Member

pi0 commented Jan 11, 2024

Thanks!

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