nsarrazin commited on
Commit
a36bf4b
·
1 Parent(s): 72becf3

fix: skip file if unavailable

Browse files
src/lib/server/api/routes/groups/misc.ts CHANGED
@@ -135,13 +135,19 @@ export const misc = new Elysia()
135
  });
136
  const files = await Promise.all(
137
  hashes.map(async (hash) => {
138
- const fileData = await downloadFile(hash, conversation._id);
139
- return fileData;
 
 
 
 
140
  })
141
  );
142
 
143
  const filenames: string[] = [];
144
  files.forEach((file) => {
 
 
145
  const extension = mimeTypes.extension(file.mime) || "bin";
146
  const convId = conversation._id.toString();
147
  const fileId = file.name.split("-")[1].slice(0, 8);
 
135
  });
136
  const files = await Promise.all(
137
  hashes.map(async (hash) => {
138
+ try {
139
+ const fileData = await downloadFile(hash, conversation._id);
140
+ return fileData;
141
+ } catch {
142
+ return null;
143
+ }
144
  })
145
  );
146
 
147
  const filenames: string[] = [];
148
  files.forEach((file) => {
149
+ if (!file) return;
150
+
151
  const extension = mimeTypes.extension(file.mime) || "bin";
152
  const convId = conversation._id.toString();
153
  const fileId = file.name.split("-")[1].slice(0, 8);