Skip to content

Commit

Permalink
removing already uploaded cids when replicate
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Apr 10, 2024
1 parent ca0e011 commit 4235b4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/react-native-fula",
"version": "1.54.18",
"version": "1.54.19",
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
15 changes: 14 additions & 1 deletion src/protocols/chain-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export const manifestNewBatch = async (
) {
newCids.push(cid);
} else {
let addCid = true;
let formattedManifestInfo: BType.ManifestResponse = JSON.parse(
JSON.stringify(manifestInfo.toHuman())
);
Expand All @@ -349,7 +350,19 @@ export const manifestNewBatch = async (
(user) => user.uploader === uploader
)
) {
newCids.push(formattedManifestInfo.manifestMetadata.job.uri);
addCid = false;
}
if (addCid && formattedManifestInfo?.manifestMetadata) {
try {
let manifestMetaData: BType.ManifestMetadata = JSON.parse(
formattedManifestInfo?.manifestMetadata
);
if (manifestMetaData?.job?.uri) {
newCids.push(manifestMetaData.job.uri);
}
} catch (e) {
console.log('error while parsing manifestMetadata');
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ export interface UserData {

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

0 comments on commit 4235b4f

Please sign in to comment.