Add -conflict postfix for files modified externally
This commit is contained in:
parent
3532cd6f1b
commit
f96944b867
@ -86,7 +86,7 @@ class SessionController extends Controller{
|
|||||||
$currentHash = sha1($view->file_get_contents($path));
|
$currentHash = sha1($view->file_get_contents($path));
|
||||||
if ($currentHash !== $session['genesis_hash']){
|
if ($currentHash !== $session['genesis_hash']){
|
||||||
// Original file was modified externally. Save to a new one
|
// Original file was modified externally. Save to a new one
|
||||||
$path = Helper::getNewFileName($view, $path);
|
$path = Helper::getNewFileName($view, $path, '-conflict');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ class Helper{
|
|||||||
|
|
||||||
const APP_ID = 'documents';
|
const APP_ID = 'documents';
|
||||||
|
|
||||||
public static function getNewFileName($view, $path){
|
public static function getNewFileName($view, $path, $prepend = ' '){
|
||||||
$fileNum = 0;
|
$fileNum = 0;
|
||||||
|
|
||||||
while ($view->file_exists($path)){
|
while ($view->file_exists($path)){
|
||||||
$fileNum += 1;
|
$fileNum += 1;
|
||||||
$path = preg_replace('/(\.odt|\(\d+\)\.odt)$/', ' (' .$fileNum . ').odt', $path);
|
$path = preg_replace('/(\.odt|' . $prepend . '\(\d+\)\.odt)$/', $prepend . '(' .$fileNum . ').odt', $path);
|
||||||
};
|
};
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user