Skip to content

Commit e1bcf5e

Browse files
authored
fix: dudewhere root cid should be content cid (#2392)
there are a few entries in DUDEWHERE bucket with CIDv0. Example: https://dash.cloudflare.com/fffa4b4363a7e5250af8357087263b3a/r2/default/buckets/dudewhere-prod-0 This won't work with reading from freeway from w3s.link when we always redirect to CIDv1
1 parent a22a1a5 commit e1bcf5e

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/api/src/bindings.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ export type Backup = {
271271
// needs to be a type so it can be assigned to Record<string, string>
272272
export type BackupMetadata = {
273273
structure: DagStructure
274-
rootCid: string
274+
sourceCid: string
275+
contentCid: string
275276
carCid: string
276277
}
277278

packages/api/src/routes/nfts-upload.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ export async function uploadCarWithStat(
140140
stat
141141
) {
142142
const sourceCid = stat.rootCid.toString()
143+
const contentCid = stat.rootCid.toV1().toString()
143144
const carCid = await createCarCid(stat.carBytes)
144145
const metadata = {
145146
structure: stat.structure || 'Unknown',
146-
rootCid: sourceCid,
147+
sourceCid,
148+
contentCid,
147149
carCid: carCid.toString(),
148150
}
149151

@@ -171,7 +173,7 @@ export async function uploadCarWithStat(
171173
const upload = await ctx.db.createUpload({
172174
mime_type: mimeType,
173175
type: uploadType,
174-
content_cid: stat.rootCid.toV1().toString(),
176+
content_cid: contentCid,
175177
source_cid: sourceCid,
176178
dag_size: stat.size,
177179
user_id: user.id,

packages/api/src/utils/uploader/r2-uploader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class R2Uploader {
4848
try {
4949
await pRetry(put, { retries: 3, onFailedAttempt: console.log })
5050
await Promise.all([
51-
this.uploadDudeWhereLink(metadata.rootCid, carCid),
51+
this.uploadDudeWhereLink(metadata.contentCid, carCid),
5252
this.uploadSatNavIndex(carBytes, carCid),
5353
])
5454
return { key, url }

packages/api/src/utils/uploader/s3-uploader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class S3Uploader {
6767
*/
6868
async uploadCar(carBytes, carCid, userId, metadata) {
6969
const carHash = uint8ArrayToString(carCid.multihash.bytes, 'base32')
70-
const key = `raw/${metadata.rootCid}/${this._appName}-${userId}/${carHash}.car`
70+
const key = `raw/${metadata.sourceCid}/${this._appName}-${userId}/${carHash}.car`
7171
const url = new URL(key, this._baseUrl.toString())
7272

7373
/** @type {import('@aws-sdk/client-s3').PutObjectCommandInput} */

0 commit comments

Comments
 (0)