mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-09-12 09:57:46 +02:00
fix(results): hide actions for failed conversions (#625)
This commit is contained in:
@@ -11,7 +11,7 @@ export const download = new Elysia()
|
|||||||
.use(userService)
|
.use(userService)
|
||||||
.get(
|
.get(
|
||||||
"/download/:userId/:jobId/:fileName",
|
"/download/:userId/:jobId/:fileName",
|
||||||
async ({ params, redirect, user }) => {
|
async ({ params, redirect, set, user }) => {
|
||||||
const userId = user.id;
|
const userId = user.id;
|
||||||
const job = await db
|
const job = await db
|
||||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
.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 fileName = sanitize(decodeURIComponent(params.fileName));
|
||||||
|
|
||||||
const filePath = `${outputDir}${userId}/${jobId}/${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,
|
auth: true,
|
||||||
|
|||||||
+41
-29
@@ -96,35 +96,47 @@ function ResultsArticle({
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{files.map((file) => (
|
{files.map((file) => {
|
||||||
<tr>
|
const conversionFailed = ["Failed, check logs", "File type not supported"].includes(
|
||||||
<td safe class="max-w-[20vw] truncate">
|
file.status,
|
||||||
{file.output_file_name}
|
);
|
||||||
</td>
|
|
||||||
<td safe>{file.status}</td>
|
return (
|
||||||
<td class="flex flex-row gap-4">
|
<tr>
|
||||||
<a
|
<td safe class="max-w-[20vw] truncate">
|
||||||
class={`
|
{file.output_file_name}
|
||||||
text-accent-500 underline
|
</td>
|
||||||
hover:text-accent-400
|
<td safe>{file.status}</td>
|
||||||
`}
|
<td class="flex flex-row gap-4">
|
||||||
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
|
{conversionFailed ? (
|
||||||
>
|
<span class="text-neutral-500">Unavailable</span>
|
||||||
<EyeIcon />
|
) : (
|
||||||
</a>
|
<>
|
||||||
<a
|
<a
|
||||||
class={`
|
class={`
|
||||||
text-accent-500 underline
|
text-accent-500 underline
|
||||||
hover:text-accent-400
|
hover:text-accent-400
|
||||||
`}
|
`}
|
||||||
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
|
href={buildDownloadUrl(WEBROOT, outputPath, file.output_file_name)}
|
||||||
download={file.output_file_name}
|
>
|
||||||
>
|
<EyeIcon />
|
||||||
<DownloadIcon />
|
</a>
|
||||||
</a>
|
<a
|
||||||
</td>
|
class={`
|
||||||
</tr>
|
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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Reference in New Issue
Block a user