fix(results): hide actions for failed conversions (#625)

This commit is contained in:
Justin Shetty
2026-09-03 11:41:57 -07:00
committed by GitHub
parent ce8637307c
commit e94d037a61
2 changed files with 49 additions and 31 deletions
+8 -2
View File
@@ -11,7 +11,7 @@ export const download = new Elysia()
.use(userService)
.get(
"/download/:userId/:jobId/:fileName",
async ({ params, redirect, user }) => {
async ({ params, redirect, set, user }) => {
const userId = user.id;
const job = await db
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
@@ -25,7 +25,13 @@ export const download = new Elysia()
const fileName = sanitize(decodeURIComponent(params.fileName));
const filePath = `${outputDir}${userId}/${jobId}/${fileName}`;
return Bun.file(filePath);
const file = Bun.file(filePath);
if (!(await file.exists())) {
set.status = 404;
return { message: "Converted file not found." };
}
return file;
},
{
auth: true,
+41 -29
View File
@@ -96,35 +96,47 @@ function ResultsArticle({
</tr>
</thead>
<tbody>
{files.map((file) => (
<tr>
<td safe class="max-w-[20vw] truncate">
{file.output_file_name}
</td>
<td safe>{file.status}</td>
<td class="flex flex-row gap-4">
<a
class={`
text-accent-500 underline
hover:text-accent-400
`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
>
<EyeIcon />
</a>
<a
class={`
text-accent-500 underline
hover:text-accent-400
`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
download={file.output_file_name}
>
<DownloadIcon />
</a>
</td>
</tr>
))}
{files.map((file) => {
const conversionFailed = ["Failed, check logs", "File type not supported"].includes(
file.status,
);
return (
<tr>
<td safe class="max-w-[20vw] truncate">
{file.output_file_name}
</td>
<td safe>{file.status}</td>
<td class="flex flex-row gap-4">
{conversionFailed ? (
<span class="text-neutral-500">Unavailable</span>
) : (
<>
<a
class={`
text-accent-500 underline
hover:text-accent-400
`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
>
<EyeIcon />
</a>
<a
class={`
text-accent-500 underline
hover:text-accent-400
`}
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
download={file.output_file_name}
>
<DownloadIcon />
</a>
</>
)}
</td>
</tr>
);
})}
</tbody>
</table>
</article>