From 631831e1e4be04ab05cdd8c61f407b420466ac94 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 19 Nov 2020 12:24:26 +0100 Subject: [PATCH] Use custom demo DB path suffix also for storage (references #395) --- services/DemoDataGeneratorService.php | 21 +++++++++++++++++---- services/FilesService.php | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/services/DemoDataGeneratorService.php b/services/DemoDataGeneratorService.php index a962c50c..23c7f463 100644 --- a/services/DemoDataGeneratorService.php +++ b/services/DemoDataGeneratorService.php @@ -290,10 +290,23 @@ class DemoDataGeneratorService extends BaseService $batteriesService->TrackChargeCycle(4, date('Y-m-d H:i:s', strtotime('-56 days'))); // Download demo storage data - $productPicturesFolder = GROCY_DATAPATH . '/storage/productpictures'; - $equipmentManualsFolder = GROCY_DATAPATH . '/storage/equipmentmanuals'; - $recipePicturesFolder = GROCY_DATAPATH . '/storage/recipepictures'; - @mkdir(GROCY_DATAPATH . '/storage'); + $storagePath = GROCY_DATAPATH . '/storage'; + @mkdir($storagePath); + if (GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease') + { + $dbSuffix = GROCY_DEFAULT_LOCALE; + if (defined('GROCY_DEMO_DB_SUFFIX')) + { + $dbSuffix = GROCY_DEMO_DB_SUFFIX; + } + + $storagePath = $storagePath . '/' . $dbSuffix; + @mkdir($storagePath); + } + + $productPicturesFolder = $storagePath . '/productpictures'; + $equipmentManualsFolder = $storagePath . '/equipmentmanuals'; + $recipePicturesFolder = $storagePath . '/recipepictures'; @mkdir($productPicturesFolder); @mkdir($equipmentManualsFolder); @mkdir($recipePicturesFolder); diff --git a/services/FilesService.php b/services/FilesService.php index b9994e80..8c1483ec 100644 --- a/services/FilesService.php +++ b/services/FilesService.php @@ -76,5 +76,21 @@ class FilesService extends BaseService { mkdir($this->StoragePath); } + + if (GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease') + { + $dbSuffix = GROCY_DEFAULT_LOCALE; + if (defined('GROCY_DEMO_DB_SUFFIX')) + { + $dbSuffix = GROCY_DEMO_DB_SUFFIX; + } + + $this->StoragePath = $this->StoragePath . '/' . $dbSuffix; + + if (!file_exists($this->StoragePath)) + { + mkdir($this->StoragePath); + } + } } }