Skip to content

Commit

Permalink
fix: avoid car repack (#2552)
Browse files Browse the repository at this point in the history
Adds call to upload/add to record uploads in web3.storage
  • Loading branch information
Gozala authored Apr 2, 2024
1 parent b31847b commit b4ff571
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
5 changes: 0 additions & 5 deletions packages/api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
} from './middleware/maintenance.js'
import { getContext } from './utils/context.js'
import { withAuth } from './middleware/auth.js'
import { repl } from './repl.js'

const r = new Router(getContext, {
onError(req, err, ctx) {
Expand All @@ -48,10 +47,6 @@ const checkHasDeleteRestriction = true
const checkHasPsaAccess = true
const checkUcan = true

// Debugging

r.add('post', '/repl', repl)

// Monitoring
r.add('get', '/metrics', withMode(metrics, RO))
r.add('get', '/stats', withMode(getStats, RO), [postCors])
Expand Down
22 changes: 0 additions & 22 deletions packages/api/src/repl.js

This file was deleted.

11 changes: 10 additions & 1 deletion packages/api/src/routes/nfts-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,16 @@ export async function uploadCarWithStat(
const { w3up } = ctx

console.log('UPLOADING CAR')
await w3up.capability.store.add(car)

// we perform store/add and upload/add concurrently to save time.
await Promise.all([
w3up.capability.store.add(car),
// We create an upload for each CAR and use it's CID as a shard, which
// will work as expected because `upload/add` merges all shards.
// @ts-expect-error Link types mismatch
w3up.capability.upload.add(stat.rootCid, [stat.cid]),
])

console.log('UPLOADED CAR')
// register as gateway links to record the CAR CID - we don't have another
// way to know the location right now.
Expand Down

0 comments on commit b4ff571

Please sign in to comment.