1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Dominik Riebeling 2012-04-26 21:17:00 +02:00
parent 07798ae526
commit b623b97d40

View file

@ -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);