Commit 47f7dfba authored by Marc Egger's avatar Marc Egger
Browse files

rename form backup directory and backup file name pattern

parent 00690ab4
Pipeline #4956 passed with stages
in 4 minutes and 16 seconds
......@@ -779,12 +779,12 @@ class FormAsFile
}
}
$cwdToBackupFile = Path::join($cwdToBackup, $formName . '.' . date('Y-m-d_H-i-s') . ".$tag.json");
$cwdToBackupFile = Path::join($cwdToBackup, $formName . '.json.' . date('Y-m-d_H-i-s') . ".$tag");
// add index to filename if backup file with current timestamp already exists
$index = 1;
while (file_exists($cwdToBackupFile)) {
$cwdToBackupFile = Path::join($cwdToBackup, $formName . '.' . date('Y-m-d_H-i-s') . ".$index.$tag.json");
$cwdToBackupFile = Path::join($cwdToBackup, $formName . '.json.' . date('Y-m-d_H-i-s') . ".$index.$tag");
$index ++;
if ($index > 20) {
Thrower::userFormException('Error while trying to backup form file.', 'Infinite loop.');
......
......@@ -57,9 +57,9 @@ class Path
private const APP_TO_PROJECT_IN_PROTECTED = 'fileadmin/protected/qfqProject';
const PROJECT_TO_FORM = 'form';
const PROJECT_TO_CONF = 'conf';
const FORM_TO_FORM_BACKUP = '_backup';
const FORM_TO_FORM_BACKUP = '.backup';
const PROJECT_DIR_TO_REPORT = 'report'; // TODO: refactor: remove DIR from constant name
const REPORT_FILE_TO_BACKUP = '_backup'; // The path from a directory containing a report file to the directory containing backups of that report file
const REPORT_FILE_TO_BACKUP = '.backup'; // The path from a directory containing a report file to the directory containing backups of that report file
// Config
const APP_TO_TYPO3_CONF = 'typo3conf';
......
......@@ -215,14 +215,14 @@ class ReportAsFile
}
}
$cwdToBackupFile = Path::join($cwdToBackup, basename($cwdToReportFile, REPORT_FILE_EXTENSION) . '.' . date('Y-m-d_H-i-s') . ".json");
$cwdToBackupFile = Path::join($cwdToBackup, basename($cwdToReportFile, REPORT_FILE_EXTENSION) . REPORT_FILE_EXTENSION . '.' . date('Y-m-d_H-i-s'));
// add index to filename if backup file with current timestamp already exists
$index = 1;
while (file_exists($cwdToBackupFile)) {
$cwdToBackupFile = Path::join($cwdToBackup, basename($cwdToReportFile, REPORT_FILE_EXTENSION) . '.' . date('Y-m-d_H-i-s') . ".$index.json");
$cwdToBackupFile = Path::join($cwdToBackup, basename($cwdToReportFile, REPORT_FILE_EXTENSION) . REPORT_FILE_EXTENSION . '.' . date('Y-m-d_H-i-s') . ".$index");
$index ++;
if ($index > 100) {
if ($index > 20) {
Thrower::userFormException('Error while trying to backup report file.', 'Infinite loop.');
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment