Mercurial > libervia-web
changeset 1612:ebd538cb26cb
server, pages (files/view): use new `use_local_shared_tmp` option.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 12 Jun 2024 23:11:08 +0200 |
parents | b695b98851fc |
children | c4407befc52a |
files | libervia/web/pages/files/view/page_meta.py libervia/web/server/server.py |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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(
--- 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())