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

feat(files): CAR Import #2323

Merged
merged 41 commits into from
Mar 5, 2025
Merged

Conversation

badgooooor
Copy link
Contributor

@badgooooor badgooooor commented Feb 3, 2025

Description

  • Close Import/export CAR DAG archives #1798
  • Add "Import CAR File", including
    • Dropdown menu in import
      image
    • CAR File import modal with file input, optional name input and validation on file name by extension
    • Add local definition of DAG from kubo to IPFSService
      Screenshot 2568-02-03 at 21 29 52
      Screenshot 2568-02-03 at 21 30 01
      Screenshot 2568-02-03 at 21 30 10

@lidel lidel changed the title Import CAR File feat(fileS): Import CAR File Feb 3, 2025
@lidel lidel changed the title feat(fileS): Import CAR File feat(files): CAR Import Feb 3, 2025
making  UI match bulk import feature
+ unifying import/export language
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @badgooooor!

I've pushed small cosmetic changes to follow similar visual language as in "Bulk import" feature added in #2307, added CLI tutor docs and unified CAR Import/Export language.

Looks good to merge on my end, but would appreciate second set of eyes on UI and language.

@SgtPooki / @2color mind taking a final look, and if looks ok, merge?

Copy link
Member

@2color 2color left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered a bug when you try to import and the name already exists. I've pushed a229aa9 to fix this, in lieu of a better way to show errors, I just throw a more helpful error.

Besides that, LGTM.

Thanks @badgooooor 🎉

@SgtPooki
Copy link
Member

SgtPooki commented Mar 5, 2025

i'm getting an error when importing:

core.ts:90 Uncaught (in promise) HTTPError: file does not exist
    at Object.errorHandler [as handleError] (core.ts:90:22)
    at async Client.fetch (http.ts:165:11)
    at async Object.stat (stat.ts:9:17)
    at async actions.js:421:7
    at async task.js:100:12
    at async task.js:199:20
    at async utils.js:139:12

commenting out changes from a229aa9 resolves this. Will look into a more robust fix.

@2color
Copy link
Member

2color commented Mar 5, 2025

@SgtPooki sorry that was oversight on my end. I used the then notation (avoiding try catch) because we swallow the error. I just pushed a small refactor to keep it leaner.

Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few small nits..

I think we should update the modal to provide a little more information.. here is a quick edit I made that I think improves clarity for users a bit (and centers the description):

image

Comment on lines +436 to +438
// TODO: Not sure why we do this. Perhaps a generic error is used
// to avoid leaking private information via Countly?
throw Object.assign(new Error('ipfs.files.cp call failed'), {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI we no longer use countly.. we need to strip it from this repo


declare export interface IPFSService extends CoreService {
pin: PinService;
files: FileService;
name: NameService;
object: ObjectService;
config: ConfigService;
dag: KuboRPCClient['dag'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that I removed the custom defined types here so we don't have to manage them later. Ideally this whole IPFSService will be going away and we'll be using types from kubo-rpc-client going forward.

"description": "Choose a CAR file to import a DAG from and specify a name for it to be imported into the current directory.",
"selectCARButtonText": "Select CAR…",
"namePlaceholder": "Name",
"renameImportPath": "Rename import"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new label for rename input

Comment on lines +412 to +413
// @ts-expect-error - https://github.com/ipfs/js-kubo-rpc-client/issues/278
const result = await all(ipfs.dag.import(stream, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubo-rpc-client types need updated.

Comment on lines +85 to +89
{/* Gray text showing original car file name */}
{ file != null
? <div className='mt1 f7 center charcoal-muted tl w-90'>{file.path}</div>
: null
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new display of original car file

<p className='mt0 center charcoal tl w-90'>{t('addByCarModal.description')}</p>
</div>

<label htmlFor='import-car-file-name' className='mt0 f7 center charcoal-muted tl w-90'>{t('addByCarModal.renameImportPath')}</label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new label for rename input

@SgtPooki SgtPooki merged commit e66590f into ipfs:main Mar 5, 2025
20 checks passed
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.

Import/export CAR DAG archives
4 participants