From b623b97d4084f1dc0d92da8d932833004e331982 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Thu, 26 Apr 2012 21:17:00 +0200 Subject: [PATCH] Check for bootloader file on device before copying. QFile::copy() doesn't overwrite an already existing file. This can lead to bootloader installation trying to place a new file on the player but failing to do the actual copy if the file already exists. Since overwriting an already existing file might be unexpected by the user error out in this case and notify the user. Change-Id: I5ffaf2f1344271ea2bad9e3232234826552385ec --- .../rbutilqt/base/bootloaderinstallfile.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/rbutil/rbutilqt/base/bootloaderinstallfile.cpp b/rbutil/rbutilqt/base/bootloaderinstallfile.cpp index 6d95106dd4..fc293e54eb 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallfile.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallfile.cpp @@ -80,11 +80,24 @@ void BootloaderInstallFile::installStage2(void) // place (new) bootloader m_tempfile.open(); - qDebug() << "[BootloaderInstallFile] renaming" << m_tempfile.fileName() << "to" << fwfile; + qDebug() << "[BootloaderInstallFile] renaming" << m_tempfile.fileName() + << "to" << fwfile; m_tempfile.close(); - m_tempfile.copy(fwfile); - emit logItem(tr("Bootloader successful installed"), LOGOK); + if(!Utils::resolvePathCase(fwfile).isEmpty()) { + emit logItem(tr("A firmware file is already present on player"), LOGERROR); + emit done(true); + return; + } + if(m_tempfile.copy(fwfile)) { + emit logItem(tr("Bootloader successful installed"), LOGOK); + } + else { + emit logItem(tr("Copying modified firmware file failed"), LOGERROR); + emit done(true); + return; + } + logInstall(LogAdd); emit done(false);