Skip to content

Commit 4235b4f

Browse files
committed
removing already uploaded cids when replicate
1 parent ca0e011 commit 4235b4f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@functionland/react-native-fula",
3-
"version": "1.54.18",
3+
"version": "1.54.19",
44
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/protocols/chain-api.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export const manifestNewBatch = async (
341341
) {
342342
newCids.push(cid);
343343
} else {
344+
let addCid = true;
344345
let formattedManifestInfo: BType.ManifestResponse = JSON.parse(
345346
JSON.stringify(manifestInfo.toHuman())
346347
);
@@ -349,7 +350,19 @@ export const manifestNewBatch = async (
349350
(user) => user.uploader === uploader
350351
)
351352
) {
352-
newCids.push(formattedManifestInfo.manifestMetadata.job.uri);
353+
addCid = false;
354+
}
355+
if (addCid && formattedManifestInfo?.manifestMetadata) {
356+
try {
357+
let manifestMetaData: BType.ManifestMetadata = JSON.parse(
358+
formattedManifestInfo?.manifestMetadata
359+
);
360+
if (manifestMetaData?.job?.uri) {
361+
newCids.push(manifestMetaData.job.uri);
362+
}
363+
} catch (e) {
364+
console.log('error while parsing manifestMetadata');
365+
}
353366
}
354367
}
355368
}

src/types/blockchain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ export interface UserData {
121121

122122
export interface ManifestResponse {
123123
usersData: UserData[];
124-
manifestMetadata: ManifestMetadata;
124+
manifestMetadata: string;
125125
size_?: number | null; // The question mark indicates that this field is optional.
126126
}

0 commit comments

Comments
 (0)