-
Notifications
You must be signed in to change notification settings - Fork 62
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: add helia-car-creator example #72
Conversation
failing test shows different car file CID, see https://github.com/ipfs-examples/helia-examples/actions/runs/5696092971/job/15440516463?pr=72#step:6:135
https://cid.ipfs.tech/#bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354 shows
https://cid.ipfs.tech/#bafybeifsknwjwoby7gmnqlzj236rcq47q5pskkum7svsevsod5a74caxry shows
|
there is definitely something sketchy going on somewhere. assuming something with playwright downloads
|
made some changes, and then ran > hyperfine 'npm run test' --show-output --ignore-failure --export-json=./testRuns.json --runs=1000 | tee testRuns.txt
[...]
> cat testRuns.json | jq '.results[0].exit_codes | {total: . | length, failed: map(select(. == 0|not)) | length }'
{
"total": 1000,
"failed": 0
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job, works great on my local! Approving in principle, some minor nits for your consideration.
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.log*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk why these were all there. probably from the other example i copied from
const downloadEl = document.createElement('a') | ||
const blobUrl = window.URL.createObjectURL(carBlob) | ||
downloadEl.href = blobUrl | ||
downloadEl.download = 'test.car' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just call it the <original_file_name>.car
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could (or first filename if multiple), but I think that's a minor thing anyone running/improving this example could do easily. will sleep on this one
|
||
const { writer, out } = await CarWriter.create(rootCID) | ||
|
||
// don't await yet.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not?
return car(helia) | ||
}, [helia]) | ||
const heliaFs = useMemo(() => { | ||
if (helia == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/Should this be DRYer?
export default function FileUploader () { | ||
const { files, setFiles } = useFiles() | ||
const handleFileEvent = useCallback((e) => { | ||
const filesToUpload = Array.prototype.slice.call(e.target.files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find this very hacky, isn't e.target.files
already an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not quite an array but I haven't looked at this part of the code in a while, I will look again
if (helia) { | ||
console.info('helia already started') | ||
} else if (window.helia) { | ||
console.info('found a windowed instance of helia, populating ...') | ||
setHelia(window.helia) | ||
setFs(unixfs(helia)) | ||
setStarting(false) | ||
} else { | ||
try { | ||
console.info('Starting Helia') | ||
const helia = await createHelia() | ||
setHelia(helia) | ||
setFs(unixfs(helia)) | ||
setStarting(false) | ||
} catch (e) { | ||
console.error(e) | ||
setError(true) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (helia) { | |
console.info('helia already started') | |
} else if (window.helia) { | |
console.info('found a windowed instance of helia, populating ...') | |
setHelia(window.helia) | |
setFs(unixfs(helia)) | |
setStarting(false) | |
} else { | |
try { | |
console.info('Starting Helia') | |
const helia = await createHelia() | |
setHelia(helia) | |
setFs(unixfs(helia)) | |
setStarting(false) | |
} catch (e) { | |
console.error(e) | |
setError(true) | |
} | |
} | |
if (helia) { | |
console.info('helia already started') | |
return | |
} | |
try { | |
const heliaInstance = window.helia || await createHelia() | |
setHelia(heliaInstance) | |
setFs(unixfs(helia)) | |
setStarting(false) | |
} catch (e) { | |
console.error(e) | |
setError(true) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was copied from helia-vite IIRC, will test this update tomorrow
export const HeliaProvider = ({ children }) => { | ||
const [helia, setHelia] = useState(null) | ||
const [fs, setFs] = useState(null) | ||
const [starting, setStarting] = useState(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing the value of this, can't just access to the instance help?
line-height: 1.5; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my 👁️ 👁️ thank you!
Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
NOTE: This example was created to assist some folks in ETHGlobal HackFS 2023 who were asking questions about how to build CAR files out of files uploaded by a user.
Things left to do: