From 7177146a566bd202b2536770184ba53a4802979b Mon Sep 17 00:00:00 2001 From: Mutzi Date: Tue, 21 May 2024 14:51:58 +0200 Subject: [PATCH] Disable timeouts for upload/download --- src/server/download.cxx | 8 ++++++++ src/server/upload.cxx | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/server/download.cxx b/src/server/download.cxx index 3232ff4..06e962a 100644 --- a/src/server/download.cxx +++ b/src/server/download.cxx @@ -34,6 +34,8 @@ net::awaitable Server::download(tcp_stream &s, const http::requestname); auto res = create_response(req); @@ -42,6 +44,8 @@ net::awaitable Server::download(tcp_stream &s, const http::requestname + "\""); res.body().open((user->user_dir / std::to_string(node->id)).c_str(), beast::file_mode::read, ec); co_await http::async_write(s, res, net::use_awaitable); + + s.expires_after(std::chrono::seconds(30)); } struct Zip : public ZipArchive { @@ -113,6 +117,8 @@ net::awaitable Server::download_multi(tcp_stream &s, const http::request sr{res}; co_await http::async_write_header(s, sr, net::use_awaitable); @@ -145,4 +151,6 @@ net::awaitable Server::download_multi(tcp_stream &s, const http::request Server::upload(tcp_stream &s, tcp_buffer &buf, http::reques std::filesystem::remove(path.replace_extension("png")); } + s.expires_never(); + std::exception_ptr ex_ptr; beast::error_code ec; body.body().open(path.c_str(), beast::file_mode::write, ec); @@ -92,6 +94,8 @@ net::awaitable Server::upload(tcp_stream &s, tcp_buffer &buf, http::reques res.keep_alive(false); co_await http::async_write(s, res, net::use_awaitable); + s.expires_after(std::chrono::seconds(30)); + if (ex_ptr) rethrow_exception(ex_ptr); }