From 1097441e9d2f9c41592a3cfe792a483b0d5601d9 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Thu, 21 Nov 2024 19:44:39 +0100 Subject: [PATCH] fix: app-data-path --- .../backend/src/common/helpers/env-helpers.ts | 5 ++++- .../src/core/config/configuration.service.ts | 2 +- packages/backend/src/modules/apps/app.helpers.ts | 2 +- .../user-settings-form/user-settings-form.tsx | 16 +++++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/common/helpers/env-helpers.ts b/packages/backend/src/common/helpers/env-helpers.ts index 235e6e6ac9..c4b87ae14a 100644 --- a/packages/backend/src/common/helpers/env-helpers.ts +++ b/packages/backend/src/common/helpers/env-helpers.ts @@ -87,6 +87,9 @@ export const generateSystemEnvFile = async (): Promise> => { ); } + // Ensure that the app data path does not contain the /app-data suffix + const fixedAppDataPath = data.appDataPath?.split('/app-data')[0]; + envMap.set('ROOT_FOLDER_HOST', rootFolderHost); envMap.set('APPS_REPO_ID', repoId); envMap.set('APPS_REPO_URL', data.appsRepoUrl || envMap.get('APPS_REPO_URL') || DEFAULT_REPO_URL); @@ -96,7 +99,7 @@ export const generateSystemEnvFile = async (): Promise> => { envMap.set('ARCHITECTURE', getArchitecture()); envMap.set('JWT_SECRET', jwtSecret); envMap.set('DOMAIN', data.domain || envMap.get('DOMAIN') || 'example.com'); - envMap.set('RUNTIPI_APP_DATA_PATH', data.appDataPath || envMap.get('RUNTIPI_APP_DATA_PATH') || rootFolderHost); + envMap.set('RUNTIPI_APP_DATA_PATH', fixedAppDataPath || envMap.get('RUNTIPI_APP_DATA_PATH') || rootFolderHost); envMap.set('POSTGRES_HOST', 'runtipi-db'); envMap.set('POSTGRES_DBNAME', 'tipi'); envMap.set('POSTGRES_USERNAME', 'tipi'); diff --git a/packages/backend/src/core/config/configuration.service.ts b/packages/backend/src/core/config/configuration.service.ts index a87e97e440..407f0eb53c 100644 --- a/packages/backend/src/core/config/configuration.service.ts +++ b/packages/backend/src/core/config/configuration.service.ts @@ -129,7 +129,7 @@ export class ConfigurationService { } if (settings.allowErrorMonitoring) { - this.initSentry({ release: this.config.version, allowSentry: true }); + this.initSentry({ release: this.config.version, allowSentry: settings.allowErrorMonitoring }); } const settingsPath = path.join(DATA_DIR, 'state', 'settings.json'); diff --git a/packages/backend/src/modules/apps/app.helpers.ts b/packages/backend/src/modules/apps/app.helpers.ts index 5fcf153343..5918fca283 100644 --- a/packages/backend/src/modules/apps/app.helpers.ts +++ b/packages/backend/src/modules/apps/app.helpers.ts @@ -1,4 +1,4 @@ -import path from 'path'; +import path from 'node:path'; import { ConfigurationService } from '@/core/config/configuration.service'; import { FilesystemService } from '@/core/filesystem/filesystem.service'; import { Injectable } from '@nestjs/common'; diff --git a/packages/frontend/src/modules/settings/components/user-settings-form/user-settings-form.tsx b/packages/frontend/src/modules/settings/components/user-settings-form/user-settings-form.tsx index 1eefe7f0fe..39637300e7 100644 --- a/packages/frontend/src/modules/settings/components/user-settings-form/user-settings-form.tsx +++ b/packages/frontend/src/modules/settings/components/user-settings-form/user-settings-form.tsx @@ -12,11 +12,21 @@ import { Controller, useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { Tooltip } from 'react-tooltip'; import validator from 'validator'; +import { z } from 'zod'; const TimeZoneSelector = lazy(() => import('@/components/timezone-selector/timezone-selector').then((module) => ({ default: module.TimeZoneSelector })), ); +const settingsSchema = z.object({ + appsRepoUrl: z.string().optional(), + localDomain: z.string().optional(), + guestDashboard: z.boolean().optional(), + allowAutoThemes: z.boolean().optional(), + allowErrorMonitoring: z.boolean().optional(), + timeZone: z.string().optional(), +}); + export type SettingsFormValues = { appsRepoUrl?: string; localDomain?: string; @@ -35,7 +45,7 @@ interface IProps { } export const UserSettingsForm = (props: IProps) => { - const { onSubmit, initialValues: initalValues, loading, currentLocale = 'en-US', submitErrors } = props; + const { onSubmit, initialValues, loading, currentLocale = 'en-US', submitErrors } = props; const { t } = useTranslation(); const validateFields = (values: SettingsFormValues) => { @@ -58,7 +68,7 @@ export const UserSettingsForm = (props: IProps) => { setError, control, formState: { errors }, - } = useForm({ values: initalValues }); + } = useForm({ values: initialValues }); useEffect(() => { if (submitErrors) { @@ -78,7 +88,7 @@ export const UserSettingsForm = (props: IProps) => { } if (Object.keys(validationErrors).length === 0) { - onSubmit(values); + onSubmit(settingsSchema.parse(values)); } };