Merge pull request #8267 from hregis/7.0_bug5

Fix: check if file name already exists
This commit is contained in:
Laurent Destailleur 2018-03-05 20:44:02 +01:00 committed by GitHub
commit 45898d26a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,18 +202,26 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
$srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto;
$result = dol_move($srcpath, $destpath);
if ($result)
if (!file_exists($destpath))
{
if ($object->id)
$result = dol_move($srcpath, $destpath);
if ($result)
{
$object->addThumbs($destpath);
if ($object->id)
{
$object->addThumbs($destpath);
}
// TODO Add revert function of addThumbs to remove for old name
//$object->delThumbs($srcpath);
setEventMessages($langs->trans("FileRenamed"), null);
}
else
{
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
// TODO Add revert function of addThumbs to remove for old name
//$object->delThumbs($srcpath);
setEventMessages($langs->trans("FileRenamed"), null);
}
else
{