Skip to content

Commit

Permalink
do not break server when one item fails (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault authored Oct 9, 2023
1 parent fe27278 commit 1c4e38f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions apps/desktop/electron/src/service/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,30 @@ export function syncFile(
const nucliaConnector = new NucliaCloud(source.kb);
return downloadFileOrLink(sourceId, item).pipe(
switchMap((data) => {
if (data.type === 'blob' && data.blob) {
return from(data.blob.arrayBuffer()).pipe(
switchMap((arrayBuffer) => {
try {
try {
if (data.type === 'blob' && data.blob) {
return from(data.blob.arrayBuffer()).pipe(
switchMap((arrayBuffer) => {
return nucliaConnector.upload(item.originalId, item.title, {
buffer: arrayBuffer,
metadata: { ...item.metadata, labels: source.labels },
});
} catch (err) {
return of({ success: false, message: `${err}` });
}
}),
);
} else if (data.type === 'text' && data.text) {
return nucliaConnector.upload(item.originalId, item.title, {
text: data.text,
metadata: { labels: source.labels },
});
} else if (data.type === 'link' && data.link) {
return nucliaConnector
.uploadLink(item.originalId, item.title, data.link)
.pipe(map(() => ({ success: true, message: '' })));
} else {
return of({ success: false, message: '' });
}),
);
} else if (data.type === 'text' && data.text) {
return nucliaConnector.upload(item.originalId, item.title, {
text: data.text,
metadata: { labels: source.labels },
});
} else if (data.type === 'link' && data.link) {
return nucliaConnector
.uploadLink(item.originalId, item.title, data.link)
.pipe(map(() => ({ success: true, message: '' })));
} else {
return of({ success: false, message: '' });
}
} catch (err) {
return of({ success: false, message: `${err}` });
}
}),
tap((res) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuclia",
"version": "2.7.0",
"version": "2.7.1",
"license": "MIT",
"author": "Nuclia.cloud",
"description": "Nuclia frontend apps and libs",
Expand Down

0 comments on commit 1c4e38f

Please sign in to comment.