fix(apps.helpers): user can install app which has no data directory
This commit is contained in:
parent
4eaf2c00c3
commit
8603e24adb
2 changed files with 6 additions and 0 deletions
|
@ -255,6 +255,11 @@ const renderTemplate = (template: string, envMap: Map<string, string>) => {
|
|||
export const copyDataDir = async (id: string) => {
|
||||
const envMap = getEnvMap(id);
|
||||
|
||||
const appDataDirExists = (await fs.promises.lstat(`/runtipi/apps/${id}/data`).catch(() => false)) as fs.Stats;
|
||||
if (!appDataDirExists || !appDataDirExists.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dataDir = await fs.promises.readdir(`/runtipi/apps/${id}/data`);
|
||||
|
||||
const processFile = async (file: string) => {
|
||||
|
|
|
@ -259,6 +259,7 @@ describe('Install app', () => {
|
|||
it('should copy and replace env variables in deeply nested .templates files in data folder', async () => {
|
||||
// arrange
|
||||
const appConfig = createAppConfig({ form_fields: [{ env_variable: 'TEST', type: 'text', label: 'test', required: true }] });
|
||||
await fs.promises.writeFile(`/runtipi/apps/${appConfig.id}/data/test.txt.template`, 'test {{TEST}}');
|
||||
await fs.promises.mkdir(`/runtipi/apps/${appConfig.id}/data/test`);
|
||||
await fs.promises.mkdir(`/runtipi/apps/${appConfig.id}/data/test/test`);
|
||||
await fs.promises.writeFile(`/runtipi/apps/${appConfig.id}/data/test/test/test.txt.template`, 'test {{TEST}}');
|
||||
|
|
Loading…
Add table
Reference in a new issue