Merge pull request #8267 from hregis/7.0_bug5
Fix: check if file name already exists
This commit is contained in:
commit
45898d26a8
@ -202,18 +202,26 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
|
|||||||
$srcpath = $upload_dir.'/'.$filenamefrom;
|
$srcpath = $upload_dir.'/'.$filenamefrom;
|
||||||
$destpath = $upload_dir.'/'.$filenameto;
|
$destpath = $upload_dir.'/'.$filenameto;
|
||||||
|
|
||||||
$result = dol_move($srcpath, $destpath);
|
if (!file_exists($destpath))
|
||||||
if ($result)
|
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user