From f7f5e72aeb22b1279ed418ac9e771014a6731339 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Sat, 14 Dec 2024 20:29:15 +0300 Subject: [PATCH] limit the sent configuration variables to the frontend. --- app/Config.py | 14 ++++++++++++++ app/main.py | 2 +- entrypoint.sh | 2 +- ui/stores/ConfigStore.js | 11 +++++------ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/Config.py b/app/Config.py index d9414b9f..69ca0532 100644 --- a/app/Config.py +++ b/app/Config.py @@ -67,6 +67,10 @@ class Config: _int_vars: tuple = ('port', 'max_workers', 'socket_timeout', 'extract_info_timeout', 'debugpy_port',) _immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available', 'ytdlp_version', 'started') _boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',) + _frontend_vars: tuple = ( + 'download_path', 'keep_archive', 'output_template', + 'ytdlp_version', 'url_host', 'url_prefix', + ) @staticmethod def get_instance(): @@ -195,3 +199,13 @@ class Config: attrs[attribute] = value return attrs + + def frontend(self) -> dict: + """ + Returns configuration variables relevant to the frontend. + + Returns: + dict: A dictionary with the frontend configuration + """ + + return {k: getattr(self, k) for k in self._frontend_vars} diff --git a/app/main.py b/app/main.py index e5c4d253..58a8d5ca 100644 --- a/app/main.py +++ b/app/main.py @@ -159,7 +159,7 @@ class Main: async def connect(self, sid, _): data: dict = { **self.queue.get(), - "config": self.config, + "config": self.config.frontend(), "tasks": [], "presets": [], } diff --git a/entrypoint.sh b/entrypoint.sh index 7f5ec3e2..5c2b77d9 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -echo "Setting umask to ${UMASK}" +echo "Setting umask to ${UMASK}, to change it set the UMASK environment variable" umask ${UMASK} echo_err() { cat <<< "$@" 1>&2; } diff --git a/ui/stores/ConfigStore.js b/ui/stores/ConfigStore.js index e33ecdf1..d8384f0e 100644 --- a/ui/stores/ConfigStore.js +++ b/ui/stores/ConfigStore.js @@ -1,14 +1,12 @@ const CONFIG_KEYS = { - isConnected: false, showForm: false, - showConsole: false, - showTasks: false, - tasks: [], app: { - host: '', - prefix: '', + download_path: '/downloads', keep_archive: false, output_template: '', + ytdlp_version: '', + url_host: '', + url_prefix: '', }, presets: [ { @@ -17,6 +15,7 @@ const CONFIG_KEYS = { } ], directories: [], + tasks: [], }; export const useConfigStore = defineStore('config', () => {