From d51071b2d36d9363080ab2a981201ee04a365de4 Mon Sep 17 00:00:00 2001 From: ro Date: Tue, 9 Jul 2024 14:27:03 -0600 Subject: [PATCH] added additional asset folders to back up script the current file backup included images, but the additional asset types such as sound files, video and docs were not being added if they existed, so those have been added. also tweaked the front end script to include the correct token for the API so the backup request doesn't fail the auth check --- app/Services/Upkeep/MaintenanceService.php | 49 +++++++------------ .../app/controllers/MaintenanceManager.js | 2 +- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/app/Services/Upkeep/MaintenanceService.php b/app/Services/Upkeep/MaintenanceService.php index 21853ff..fbcf883 100644 --- a/app/Services/Upkeep/MaintenanceService.php +++ b/app/Services/Upkeep/MaintenanceService.php @@ -8,10 +8,14 @@ use Carbon\Carbon; class MaintenanceService { protected $settings; + protected $filePaths = []; public function __construct(SettingsService $settingsService) { - $this->settings = $settingsService; + $this->settings = $settingsService; + $this->filePaths = ['../public/assets/images/blog', + '../public/assets/images/user', '../public/assets/docs/blog', + '../public/assets/video/blog', '../public/assets/sound/blog']; } public function createContentBackUp() @@ -133,36 +137,21 @@ class MaintenanceService \ZipArchive::CREATE | \ZipArchive::OVERWRITE ); //gather data and path info for blog images - $blogImagesPath = '../public/assets/images/blog'; - $yearPaths = glob($blogImagesPath . '/*', GLOB_ONLYDIR); - foreach ($yearPaths as $years) { - $year = explode('/', $years); - $monthsPath = glob($blogImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR); - foreach ($monthsPath as $months) { - $month = explode('/', $months); - //once info is collected, add images pages to zip - $options = [ - 'add_path' => 'public/assets/images/blog/' . $year[5] . '/' . $month[6] . '/', - 'remove_all_path' => true, - ]; - $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); - } - } - //gather data and path info for user images - $userImagesPath = '../public/assets/images/user'; - $yearPaths = glob($userImagesPath . '/*', GLOB_ONLYDIR); - foreach ($yearPaths as $years) { - $year = explode('/', $years); - $monthsPath = glob($userImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR); - foreach ($monthsPath as $months) { - $month = explode('/', $months); - //once info is collected, add images pages to zip - $options = [ - 'add_path' => 'public/assets/images/user/' . $year[5] . '/' . $month[6] . '/', - 'remove_all_path' => true, - ]; - $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); + foreach ($this->filePaths as $path) { + $yearPaths = glob($path . '/*', GLOB_ONLYDIR); + foreach ($yearPaths as $years) { + $year = explode('/', $years); + $monthsPath = glob($path . '/' . $year[5] . '/*', GLOB_ONLYDIR); + foreach ($monthsPath as $months) { + $month = explode('/', $months); + //once info is collected, add images pages to zip + $options = [ + 'add_path' => substr($path, 3) . '/' . $year[5] . '/' . $month[6] . '/', + 'remove_all_path' => true, + ]; + $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); + } } } diff --git a/public/assets/scripts/dash/app/controllers/MaintenanceManager.js b/public/assets/scripts/dash/app/controllers/MaintenanceManager.js index ce961c9..8f92c53 100644 --- a/public/assets/scripts/dash/app/controllers/MaintenanceManager.js +++ b/public/assets/scripts/dash/app/controllers/MaintenanceManager.js @@ -281,7 +281,7 @@ class MaintenanceManager { } }; if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) { - if (eventType === TASK_UPLOAD_FILES) + if (eventType === TASK_UPLOAD_FILES || eventType === TASK_BACKUP_CREATE) request.setRequestHeader('fipamo-access-token', self.token); switch (contentType) { case CONTENT_TYPE_JSON: