aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-03-01 00:02:43 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-03-01 00:06:03 +0100
commitb4572c6217e869a236dc779120de1b057e30c652 (patch)
treecf8829258093e94af4f673a9d5adf889961d50ab
parentfb8896bccd96a11d77c7328c067ce674c72c5d36 (diff)
page.c: Do not get filename on previews
This change should provide the same behaviour, but would avoid unnecessary calls to dynstr_append and basename(3) when a preview is to be served.
-rw-r--r--page.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/page.c b/page.c
index f6e3a88..6c58ab1 100644
--- a/page.c
+++ b/page.c
@@ -1305,7 +1305,15 @@ static int serve_file(struct http_response *const r,
dynstr_init(&b);
dynstr_init(&d);
- if (dynstr_append(&b, "%s", res))
+ if (preview)
+ {
+ if (dynstr_append(&d, "inline"))
+ {
+ fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
+ goto end;
+ }
+ }
+ else if (dynstr_append(&b, "%s", res))
{
fprintf(stderr, "%s: dynstr_append res failed\n", __func__);
goto end;
@@ -1315,14 +1323,6 @@ static int serve_file(struct http_response *const r,
fprintf(stderr, "%s: basename(3) failed\n", __func__);
goto end;
}
- else if (preview)
- {
- if (dynstr_append(&d, "inline"))
- {
- fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
- goto end;
- }
- }
else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn))
{
fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__);