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',)
_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}

View file

@ -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": [],
}

View file

@ -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; }

View file

@ -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', () => {