# HG changeset patch # User Goffi # Date 1718226668 -7200 # Node ID ebd538cb26cbf32153985076a5ca397d9cb4a3b9 # Parent b695b98851fcc382d8206ec864824e816a28ad9c server, pages (files/view): use new `use_local_shared_tmp` option. diff -r b695b98851fc -r ebd538cb26cb libervia/web/pages/files/view/page_meta.py --- a/libervia/web/pages/files/view/page_meta.py Wed Jun 12 23:09:49 2024 +0200 +++ b/libervia/web/pages/files/view/page_meta.py Wed Jun 12 23:11:08 2024 +0200 @@ -1,6 +1,7 @@ #!/usr/bin/env python3 +from pathlib import Path from libervia.web.server.constants import Const as C from libervia.backend.core.i18n import _ from twisted.web import static @@ -39,7 +40,7 @@ basename = path_elts[-1] dir_elts = path_elts[:-1] dir_path = "/".join(dir_elts) - tmp_dir = tempfile.mkdtemp() + tmp_dir = tempfile.mkdtemp(dir=self.host.local_shared_path) dest_path = os.path.join(tmp_dir, basename) request.notifyFinish().addCallback(cleanup, tmp_dir, dest_path) progress_id = await self.host.bridge_call( diff -r b695b98851fc -r ebd538cb26cb libervia/web/server/server.py --- a/libervia/web/server/server.py Wed Jun 12 23:09:49 2024 +0200 +++ b/libervia/web/server/server.py Wed Jun 12 23:11:08 2024 +0200 @@ -223,6 +223,8 @@ if not self.options["port_https_ext"]: self.options["port_https_ext"] = self.options["port_https"] + self.local_shared_path: Path|None = None + self._cleanup = [] self.sessions = {} # key = session value = user @@ -455,6 +457,15 @@ self.media_dir = await self.bridge_call("config_get", "", "media_dir") self.local_dir = await self.bridge_call("config_get", "", "local_dir") self.cache_root_dir = os.path.join(self.local_dir, C.CACHE_DIR) + + use_local_shared_tmp = C.bool(config.config_get( + self.main_conf, "", "use_local_shared_tmp", C.BOOL_FALSE + )) + if use_local_shared_tmp: + C.LOCAL_SHARED_DIR = "_SHARED_TMP" + self.local_shared_path = self.cache_root_dir / Path(C.LOCAL_SHARED_DIR) + self.local_shared_path.mkdir(0o700, parents=True, exist_ok=True) + self.renderer = template.Renderer(self, self._front_url_filter) sites_names = list(self.renderer.sites_paths.keys())