Skip to content

Commit 16e7cf6

Browse files
committed
fix: skip file if unavailable
1 parent 8424e14 commit 16e7cf6

File tree

1 file changed

+8
-2
lines changed
  • src/lib/server/api/routes/groups

1 file changed

+8
-2
lines changed

src/lib/server/api/routes/groups/misc.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,19 @@ export const misc = new Elysia()
135135
});
136136
const files = await Promise.all(
137137
hashes.map(async (hash) => {
138-
const fileData = await downloadFile(hash, conversation._id);
139-
return fileData;
138+
try {
139+
const fileData = await downloadFile(hash, conversation._id);
140+
return fileData;
141+
} catch {
142+
return null;
143+
}
140144
})
141145
);
142146

143147
const filenames: string[] = [];
144148
files.forEach((file) => {
149+
if (!file) return;
150+
145151
const extension = mimeTypes.extension(file.mime) || "bin";
146152
const convId = conversation._id.toString();
147153
const fileId = file.name.split("-")[1].slice(0, 8);

0 commit comments

Comments
 (0)