limit the sent configuration variables to the frontend.

This commit is contained in:
ArabCoders 2024-12-14 20:29:15 +03:00
parent 4b322a6f5a
commit f7f5e72aeb
4 changed files with 21 additions and 8 deletions

View file

@ -67,6 +67,10 @@ class Config:
_int_vars: tuple = ('port', 'max_workers', 'socket_timeout', 'extract_info_timeout', 'debugpy_port',) _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') _immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available', 'ytdlp_version', 'started')
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',) _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 @staticmethod
def get_instance(): def get_instance():
@ -195,3 +199,13 @@ class Config:
attrs[attribute] = value attrs[attribute] = value
return attrs 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}

View file

@ -159,7 +159,7 @@ class Main:
async def connect(self, sid, _): async def connect(self, sid, _):
data: dict = { data: dict = {
**self.queue.get(), **self.queue.get(),
"config": self.config, "config": self.config.frontend(),
"tasks": [], "tasks": [],
"presets": [], "presets": [],
} }

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
echo "Setting umask to ${UMASK}" echo "Setting umask to ${UMASK}, to change it set the UMASK environment variable"
umask ${UMASK} umask ${UMASK}
echo_err() { cat <<< "$@" 1>&2; } echo_err() { cat <<< "$@" 1>&2; }

View file

@ -1,14 +1,12 @@
const CONFIG_KEYS = { const CONFIG_KEYS = {
isConnected: false,
showForm: false, showForm: false,
showConsole: false,
showTasks: false,
tasks: [],
app: { app: {
host: '', download_path: '/downloads',
prefix: '',
keep_archive: false, keep_archive: false,
output_template: '', output_template: '',
ytdlp_version: '',
url_host: '',
url_prefix: '',
}, },
presets: [ presets: [
{ {
@ -17,6 +15,7 @@ const CONFIG_KEYS = {
} }
], ],
directories: [], directories: [],
tasks: [],
}; };
export const useConfigStore = defineStore('config', () => { export const useConfigStore = defineStore('config', () => {