diff --git a/ajax/sessionController.php b/ajax/sessionController.php index 04f90b3a..f477dea4 100644 --- a/ajax/sessionController.php +++ b/ajax/sessionController.php @@ -86,7 +86,7 @@ class SessionController extends Controller{ $currentHash = sha1($view->file_get_contents($path)); if ($currentHash !== $session['genesis_hash']){ // Original file was modified externally. Save to a new one - $path = Helper::getNewFileName($view, $path); + $path = Helper::getNewFileName($view, $path, '-conflict'); } } diff --git a/lib/helper.php b/lib/helper.php index 8b4743a4..5ceeb1b0 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -15,12 +15,12 @@ class Helper{ const APP_ID = 'documents'; - public static function getNewFileName($view, $path){ + public static function getNewFileName($view, $path, $prepend = ' '){ $fileNum = 0; while ($view->file_exists($path)){ $fileNum += 1; - $path = preg_replace('/(\.odt|\(\d+\)\.odt)$/', ' (' .$fileNum . ').odt', $path); + $path = preg_replace('/(\.odt|' . $prepend . '\(\d+\)\.odt)$/', $prepend . '(' .$fileNum . ').odt', $path); }; return $path;