summaryrefslogtreecommitdiff
path: root/download.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2024-08-29 17:46:14 +0200
committerVincent Douillet <vincent@vdouillet.fr>2024-08-29 21:53:35 +0200
commitf005928d63165d28b32851f04f29055a4d0cdad5 (patch)
tree5386f28a558046dbe6e93b439f5e026441224c56 /download.c
parent4be89075c5bb5793f8c79da8f8df1accc1f0168f (diff)
get data dir from env variable
Diffstat (limited to 'download.c')
-rw-r--r--download.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/download.c b/download.c
index bff1dd6..a8f5947 100644
--- a/download.c
+++ b/download.c
@@ -79,7 +79,7 @@ build_download_url(struct kreq * r, struct file * file)
struct http_ret
download(struct kreq * r)
{
- char *file_name;
+ char *file_name, *data_dir;
void *buffer;
struct file *f;
int fd;
@@ -93,6 +93,16 @@ download(struct kreq * r)
KHTTP_200, ""
};
+ /* check that data dir is configured */
+ data_dir = config_data_dir();
+ if (data_dir == NULL) {
+ ret = (struct http_ret) {
+ KHTTP_400,
+ "download: data dir not configured"
+ };
+ goto end;
+ }
+
/* check that the requested URL can be safely processed */
if (strlen(r->path) == 0 || !check_request_path(r->path, r->suffix)) {
ret = (struct http_ret) {
@@ -122,7 +132,7 @@ download(struct kreq * r)
}
}
- path_size = url_build(file_path, PATH_MAX, DATA_DIR, request_path,
+ path_size = url_build(file_path, PATH_MAX, data_dir, request_path,
NULL);
if (path_size == 0) {
ret = (struct http_ret) {