From b876ddd2956d83098ea3793e66f9048cdcf06fa3 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 19 May 2015 10:54:24 +0100 Subject: [PATCH] Added check if rename was successful --- includes/functions.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index c66dff623..02115e133 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -229,9 +229,13 @@ function renamehost($id, $new, $source = 'console') // FIXME does not check if destination exists! $host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id)); - rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new"); - dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id)); - log_event("Hostname changed -> $new ($source)", $id, 'system'); + if (rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new") === TRUE) { + dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id)); + log_event("Hostname changed -> $new ($source)", $id, 'system'); + } else { + echo "Renaming of $host failed\n"; + log_event("Renaming of $host failed", $id, 'system'); + } } function delete_device($id)